Exemplo n.º 1
0
    def __init__(self, obj, parent=None):
        """ 
        Constructor method.
        Receives the reference to the Blender object.
        """
        logger.info('%s initialization' % obj.name)
        # Call the constructor of the parent class
        GraspingRobot.__init__(self, obj, parent)
        """
        We define here the name of the pr2 grasping hand:
        """
        self.hand_name = 'Hand.Grasp.PR2'

        self.armatures = []
        # Search armatures and torso in all objects parented to the pr2 empty
        for obj in self.bge_object.childrenRecursive:
            # Check if obj is an armature
            if type(obj).__name__ == 'BL_ArmatureObject':
                self.armatures.append(obj.name)
            if obj.name == 'torso_lift_joint':
                self.torso = obj

        # constant that holds the original height of the torso from the ground
        # These values come from the pr2 urdf file
        self.TORSO_BASE_HEIGHT = (0.739675 + 0.051)
        self.TORSO_LOWER = 0.0  # lower limit on the torso z-translantion
        self.TORSO_UPPER = 0.31  # upper limit on the torso z-translation

        logger.info('Component initialized')
Exemplo n.º 2
0
    def __init__(self, obj, parent=None):
        """ 
        Constructor method.
        Receives the reference to the Blender object.
        """
        logger.info('%s initialization' % obj.name)
        # Call the constructor of the parent class
        GraspingRobot.__init__(self, obj, parent)

        """
        We define here the name of the pr2 grasping hand:
        """
        self.hand_name = 'Hand.Grasp.PR2'

        self.armatures = []
        # Search armatures and torso in all objects parented to the pr2 empty
        for obj in self.bge_object.childrenRecursive:
            # Check if obj is an armature
            if type(obj).__name__ == 'BL_ArmatureObject':
                self.armatures.append(obj.name)
            if obj.name == 'torso_lift_joint':
                self.torso = obj

        # constant that holds the original height of the torso from the ground
        # These values come from the pr2 urdf file
        self.TORSO_BASE_HEIGHT = (0.739675 + 0.051)
        self.TORSO_LOWER = 0.0  # lower limit on the torso z-translantion
        self.TORSO_UPPER = 0.31  # upper limit on the torso z-translation
        
        logger.info('Component initialized')
Exemplo n.º 3
0
    def __init__(self, obj, parent=None):
        # Call the constructor of the parent class
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        # We define here the name of the human grasping hand:
        self.hand_name = 'Hand_Grab.R'

        logger.info('Component initialized')
Exemplo n.º 4
0
    def __init__(self, obj, parent=None):
        """ Call the constructor of the parent class """
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        # We define here the name of the human grasping hand:
        self.hand_name = 'Hand_Grab.R'

        logger.info('Component initialized')
Exemplo n.º 5
0
    def __init__(self, obj, parent=None):
        """ 
        Constructor method.
        Receives the reference to the Blender object.
        """
        logger.info('%s initialization' % obj.name)
        # Call the constructor of the parent class
        GraspingRobot.__init__(self, obj, parent)
        """
        # We define here the name of the pr2 grasping hand:
        """
        self.hand_name = 'Hand.Grasp.PR2'

        self.armatures = []
        # Search armatures and torso in all objects parented to the pr2 empty
        for obj in self.bge_object.childrenRecursive:
            # Check if obj is an armature
            if type(obj).__name__ == 'BL_ArmatureObject':
                self.armatures.append(obj.name)
                logger.info(obj.name)
                logger.info(' ==\n')
            if obj.name == 'torso_lift_joint':
                self.torso = obj
                logger.info(' ==\n')

        # constant that holds the original height of the torso from the ground
        # These values come from the pr2 urdf file
        self.TORSO_BASE_HEIGHT = (0.739675 + 0.051)
        self.TORSO_LOWER = 0.0  # lower limit on the torso z-translantion
        self.TORSO_UPPER = 0.31  # upper limit on the torso z-translation

        self.MIN_DIST = 0.85
        self.cancel = False
        self.is_ho = False
        self.is_gr = False  # is grasping?

        # raise both hands up
        scene = blenderapi.scene()

        hand_l = scene.objects['l_elbow_flex_joint']
        hand_l.worldOrientation = [
            math.radians(0),
            math.radians(-90),
            math.radians(180)
        ]

        hand_r = scene.objects['r_elbow_flex_joint']
        hand_r.worldOrientation = [
            math.radians(90),
            math.radians(-90),
            math.radians(-90)
        ]

        head = scene.objects['head_tilt_joint']
        head.worldOrientation = [0, 0, math.radians(90)]

        logger.info('Component initialized')
Exemplo n.º 6
0
    def __init__(self, obj, parent=None):
        """ Constructor method.
            Receives the reference to the Blender object.
            Optionally it gets the name of the object's parent,
            but that information is not currently used for a robot. """
        # Call the constructor of the parent class
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)
        """
        We define here the name of the human_mocap grasping hand.
        """
        self.hand_name = 'Hand_Grab.R'

        logger.info('Component initialized')
Exemplo n.º 7
0
    def __init__(self, obj, parent=None):
        """ Constructor method.
            Receives the reference to the Blender object.
            Optionally it gets the name of the object's parent,
            but that information is not currently used for a robot. """
        # Call the constructor of the parent class
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        """
        We define here the name of the human_mocap grasping hand.
        """
        self.hand_name = 'Hand_Grab.R'

        logger.info('Component initialized')
Exemplo n.º 8
0
    def __init__(self, obj, parent=None):
        """ Call the constructor of the parent class """
        logger.info("%s initialization" % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        # We define here the name of the human grasping hand:
        # self.hand_name = 'Hand_Grab.R'

        armatures = blenderapi.get_armatures(self.bge_object)
        if len(armatures) == 0:
            logger.error("The human <%s> has not armature. Something is wrong!" % obj.name)
            return
        if len(armatures) > 1:
            logger.warning("The human <%s> has more than one armature. Using the first one" % obj.name)

        self.armature = armatures[0]

        logger.info("Component initialized")
Exemplo n.º 9
0
    def apply_speed(self, kind, linear_speed, angular_speed):
        """
        Apply speed parameter to the human.

        This overloaded version of Robot.apply_speed manage the walk/rest
        animations of the human avatar.

        :param string kind: not used. Forced to 'Position' control for now.
        :param list linear_speed: the list of linear speed to apply, for
        each axis, in m/s.
        :param list angular_speed: the list of angular speed to apply,
        for each axis, in rad/s.
        """

        # TODO: adjust this value depending on linear_speed to avoid 'slipping'
        speed_factor = 1.0

        # start/end frames of walk cycle in human_rig.blend
        # TODO: get that automatically from the timeline?
        WALK_START_FRAME = 9
        WALK_END_FRAME = 32

        if self._animations:
            if linear_speed[0] != 0 or angular_speed[2] != 0:
                self.armature.playAction("walk",
                                         WALK_START_FRAME,
                                         WALK_END_FRAME,
                                         speed=speed_factor)
            else:
                self.armature.playAction("walk", WALK_START_FRAME,
                                         WALK_START_FRAME)

        if kind != 'Position':
            if not self.warnedAboutControlType:
                logger.error(
                    "Only the control type 'Position' is currently supported "
                    "by the human avatar! You need to configure accordingly"
                    " your motion actuator (for example, "
                    "\"motion.properties(ControlType='Position')\")")
                self.warnedAboutControlType = True
        else:
            GraspingRobot.apply_speed(self, 'Position', linear_speed,
                                      angular_speed)
Exemplo n.º 10
0
    def apply_speed(self, kind, linear_speed, angular_speed):
        """
        Apply speed parameter to the human.

        This overloaded version of Robot.apply_speed manage the walk/rest
        animations of the human avatar.

        :param string kind: not used. Forced to 'Position' control for now.
        :param list linear_speed: the list of linear speed to apply, for
        each axis, in m/s.
        :param list angular_speed: the list of angular speed to apply,
        for each axis, in rad/s.
        """

        # TODO: adjust this value depending on linear_speed to avoid 'slipping'
        speed_factor = 1.0

        # start/end frames of walk cycle in human_rig.blend
        # TODO: get that automatically from the timeline?
        WALK_START_FRAME = 9
        WALK_END_FRAME = 32

        if self._animations:
            if linear_speed[0] != 0 or angular_speed[2] != 0:
                self.armature.playAction("walk", 
                                        WALK_START_FRAME, WALK_END_FRAME, 
                                        speed=speed_factor)
            else:
                self.armature.playAction("walk", 
                                        WALK_START_FRAME, WALK_START_FRAME)


        if kind != 'Position':
            if not self.warnedAboutControlType:
                logger.error("Only the control type 'Position' is currently supported "
                            "by the human avatar! You need to configure accordingly"
                            " your motion actuator (for example, "
                            "\"motion.properties(ControlType='Position')\")")
                self.warnedAboutControlType = True
        else:
            GraspingRobot.apply_speed(self, 'Position', linear_speed, angular_speed)
Exemplo n.º 11
0
    def __init__(self, obj, parent=None):
        """ Call the constructor of the parent class """
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        # We define here the name of the human grasping hand:
        self.hand_name = 'Hand_Grab.R'

        self.MIN_DIST = 0.8

        # these are to feed the human action back to the system (current state)
        self.is_wa = False  # is human walking away
        self.is_gr = False  # is human grasping

        self.is_la = False  # is human looking around
        self.is_wr = False  # is human warning the robot
        self.is_ag = False  # is human attempting to grasp

        self.is_ov = True  # is the object visible to human
        self.is_oir = True  # is the object reachable to human
        self.is_ho = False  # if human has the object

        logger.info('Component initialized')
Exemplo n.º 12
0
    def __init__(self, obj, parent=None):
        """ Call the constructor of the parent class """
        logger.info('%s initialization' % obj.name)
        GraspingRobot.__init__(self, obj, parent)

        # We define here the name of the human grasping hand:
        #self.hand_name = 'Hand_Grab.R'

        armatures = blenderapi.get_armatures(self.bge_object)
        if len(armatures) == 0:
            logger.error(
                "The human <%s> has not armature. Something is wrong!" %
                obj.name)
            return
        if len(armatures) > 1:
            logger.warning(
                "The human <%s> has more than one armature. Using the first one"
                % obj.name)

        self.armature = armatures[0]

        logger.info('Component initialized')

        self.warnedAboutControlType = False