def __init__(self, name = None, debug = True): # theman.blend is located in the data/robots directory Robot.__init__(self, 'test_1/robots/theman.blend', name) self.properties(classpath = "test_1.robots.theman.Theman") self.suffix = self.name[-4:] if self.name[-4] == "." else "" try: self.armature = Armature("Armature" + self.suffix, "human_posture") # self.armature = Armature("Armature") self.append(self.armature) self.armature_pose = ArmaturePose() # armature_pose = joint states self.armature_pose.name="pose" self.armature.append(self.armature_pose) self.joint_state = CompoundSensor([self.armature_pose]) self.append(self.joint_state) except KeyError: logger.error("Could not find the human armature! (I was looking " +\ "for an object called 'Armature' in the human" +\ " children). I won't be able to export the human pose" +\ " to any middleware.") ################################### # Actuators ################################### # (v,w) motion controller # Check here the other available actuators: # http://www.openrobots.org/morse/doc/stable/components_library.html#actuators # self.motion = MotionVW() # self.append(self.motion) # Optionally allow to move the robot with the keyboard if debug: keyboard = Keyboard() self.append(keyboard) ################################### # Sensors ################################### self.pose = Pose() self.append(self.pose)
def __init__(self, filename='human'): """ The 'style' parameter is only to switch to the mocap_human file. :param filename: 'human' (default) or 'mocap_human' """ Robot.__init__(self, filename) self.suffix = self.name[-4:] if self.name[-4] == "." else "" self.armature = None if filename == 'mocap_human': self.properties( classpath="morse.robots.mocap_human.MocapHumanClass") else: self.properties(classpath="morse.robots.human.HumanClass") try: self.armature = Armature("HumanArmature" + self.suffix, "human_posture") # new way of loading class (drop 'Class' and 'Path' properties) self.armature.properties( classpath="morse.sensors.human_posture.HumanPosture") self.append(self.armature) except KeyError: logger.error("Could not find the human armature! (I was looking " +\ "for an object called 'HumanArmature' in the human" +\ " children). I won't be able to export the human pose" +\ " to any middleware.") # fix for Blender 2.6 Animations armature_object = self.get_child(self.armature.name) if armature_object: hips = self.get_child("Hips_Empty") # IK human has no object called Hips_Empty, so avoid this step if hips: for i, actuator in enumerate(hips.game.actuators): actuator.layer = i for i, actuator in enumerate(armature_object.game.actuators): actuator.layer = i