示例#1
0
文件: models.py 项目: shareeff/phobos
def deriveJoint(obj, logging=False, adjust=False, errors=None):
    """Derives a joint from a blender object and creates its initial phobos data structure.

    Args:
      obj(bpy.types.Object): object to derive the joint from
      adjust(bool, optional): TODO (Default value = False)
      logging: (Default value = False)
      errors: (Default value = None)

    Returns:
      : dict

    """
    joint_type, crot = jointmodel.deriveJointType(obj,
                                                  adjust=adjust,
                                                  logging=logging)
    props = initObjectProperties(obj,
                                 phobostype='joint',
                                 ignoretypes=linkobjignoretypes - {'joint'})

    parent = sUtils.getEffectiveParent(obj)
    props['parent'] = nUtils.getObjectName(parent)
    props['child'] = nUtils.getObjectName(obj)
    axis, minmax = jointmodel.getJointConstraints(obj)
    if axis:
        props['axis'] = list(axis)
    limits = {}
    if minmax is not None:
        # prismatic or revolute joint, TODO: planar etc.
        if len(minmax) == 2:
            limits['lower'] = minmax[0]
            limits['upper'] = minmax[1]
    if 'maxvelocity' in props:
        limits['velocity'] = props['maxvelocity']
        del props['maxvelocity']
    if 'maxeffort' in props:
        limits['effort'] = props['maxeffort']
        del props['maxeffort']
    if limits != {}:
        props['limits'] = limits
    props['pose'] = deriveObjectPose(obj)
    # TODO: what about these?
    # - calibration
    # - dynamics
    # - mimic
    # - safety_controller
    return props
示例#2
0
def deriveJoint(obj, adjust=True):
    """This function derives a joint from a blender object and creates its initial phobos data structure.

    Args:
      obj: The blender object to derive the joint from.
      adjust:  (Default value = True)

    Returns:
      dict

    """
    if 'joint/type' not in obj.keys():
        jt, crot = jointmodel.deriveJointType(obj, adjust=adjust)
    props = initObjectProperties(obj,
                                 phobostype='joint',
                                 ignoretypes=linkobjignoretypes - {'joint'})

    parent = sUtils.getEffectiveParent(obj)
    props['parent'] = nUtils.getObjectName(parent)
    props['child'] = nUtils.getObjectName(obj)
    axis, minmax = jointmodel.getJointConstraints(obj)
    if axis:
        props['axis'] = list(axis)
    limits = {}
    if minmax is not None:
        # prismatic or revolute joint, TODO: planar etc.
        if len(minmax) == 2:
            limits['lower'] = minmax[0]
            limits['upper'] = minmax[1]
    if 'maxvelocity' in props:
        limits['velocity'] = props['maxvelocity']
        del props['maxvelocity']
    if 'maxeffort' in props:
        limits['effort'] = props['maxeffort']
        del props['maxeffort']
    if limits != {}:
        props['limits'] = limits
    # TODO: what about these?
    # - calibration
    # - dynamics
    # - mimic
    # - safety_controller
    return props