def getPau(): msg = hrmsg.pau() head = api.getHeadData() msg.m_headRotation.x = head['x'] msg.m_headRotation.y = head['y'] msg.m_headRotation.z = -head['z'] msg.m_headRotation.w = head['w'] neck = api.getNeckData() msg.m_neckRotation.x = neck['x'] msg.m_neckRotation.y = neck['y'] msg.m_neckRotation.z = -neck['z'] msg.m_neckRotation.w = neck['w'] eyes = api.getEyesData() msg.m_eyeGazeLeftPitch = eyes['l']['p'] msg.m_eyeGazeLeftYaw = eyes['l']['y'] msg.m_eyeGazeRightPitch = eyes['r']['p'] msg.m_eyeGazeRightYaw = eyes['r']['y'] shapekeys = api.getFaceData() msg.m_coeffs = shapekeys.values() angles = api.getArmsData() msg.m_angles = angles.values() # Manage timeout for set_pau if api.pauTimeout < time.time(): api.setAnimationMode(api.pauAnimationMode & ~api.PAU_ACTIVE) return msg
def test_motor2(self): msg = pau() msg.m_neckRotation.x = 1.0 msg.m_neckRotation.y = 0.5 msg.m_neckRotation.z = 0.0 msg.m_neckRotation.w = 1.0 sub = self.queue.subscribe('/pub_topic2_controller/command', Float64) rospy.sleep(2) self.check_msg(msg, 0.5) # max = 0.5 sub.unregister()
def test_motor1(self): msg = pau() msg.m_headRotation.x = 0.5 msg.m_headRotation.y = 0.5 msg.m_headRotation.z = 0.0 msg.m_headRotation.w = 1.0 sub = self.queue.subscribe('/pub_topic_controller/command', Float64) rospy.sleep(2) self.check_msg(msg, math.asin(0.5)) sub.unregister()
def getPauFromMotors(motors): global msg msg = pau() msg.m_shapekeys = [-1.0]*len(ShapekeyStore._shkey_list) for m,v in motors.items(): #Get the shapekey and the value cfg = get_cfg(m) if not cfg: print("No motor config {}".format(m)) continue if cfg['function'] == 'weightedsum': weightedsum(cfg, v) if cfg['function'] == 'linear': linear(cfg, v) return msg
def getPauFromMotors(motors): global msg msg = pau() msg.m_shapekeys = [-1.0] * len(ShapekeyStore._shkey_list) for m, v in motors.items(): #Get the shapekey and the value cfg = get_cfg(m) if not cfg: print("No motor config {}".format(m)) continue if cfg['function'] == 'weightedsum': weightedsum(cfg, v) if cfg['function'] == 'linear': linear(cfg, v) return msg
def point_head(self, req): msg = pau() msg.m_headRotation = Quaternion( *Quat.Quat.fromInYZX(req.roll, -req.yaw, -req.pitch).params ) self.pub_neck.publish(msg)
from rospkg import RosPack ROBOT = "sophia_body" #import bpy #rospy.init_node("expression_tools") motors = rospy.get_param('/{}/motors'.format(ROBOT)) expressions = rospy.get_param('/{}/expressions'.format(ROBOT)) animations = rospy.get_param('/{}/animations'.format(ROBOT)) from hr_msgs.msg import pau from pau2motors import ShapekeyStore rp = RosPack() config_root = rp.get_path('robots_config') with open(config_root+"/"+ROBOT+"/motors_settings.yaml", 'r') as stream: motors = yaml.load(stream) msg = pau() msg.m_shapekeys = [-1.0]*len(ShapekeyStore._shkey_list) def get_motor_value(motor, relative): for m in motors: if m['name'] == motor: v = m['min']+relative*(m['max'] - m['min']) return int(v) return -1 def get_cfg(motor): global motors for m in motors: if m['name'] == motor: return m return None
ROBOT = "sophia_body" #import bpy #rospy.init_node("expression_tools") motors = rospy.get_param('/{}/motors'.format(ROBOT)) expressions = rospy.get_param('/{}/expressions'.format(ROBOT)) animations = rospy.get_param('/{}/animations'.format(ROBOT)) from hr_msgs.msg import pau from pau2motors import ShapekeyStore rp = RosPack() config_root = rp.get_path('robots_config') with open(config_root + "/" + ROBOT + "/motors_settings.yaml", 'r') as stream: motors = yaml.load(stream) msg = pau() msg.m_shapekeys = [-1.0] * len(ShapekeyStore._shkey_list) def get_motor_value(motor, relative): for m in motors: if m['name'] == motor: v = m['min'] + relative * (m['max'] - m['min']) return int(v) return -1 def get_cfg(motor): global motors for m in motors: if m['name'] == motor:
def point_head(self, req): msg = pau() msg.m_headRotation = Quaternion( *Quat.Quat.fromInYZX(req.roll, -req.yaw, -req.pitch).params) self.pub_neck.publish(msg)