def map_pau(selfself, trackMsg):
        #  Final Message to be sent. Currently only m_coeffs has to be remapped
        msg = pau()
        #eyes and head remains same.
        msg.m_headRotation = copy.deepcopy(trackMsg.m_headRotation)
        # Correction
        msg.m_headRotation.y = trackMsg.m_headRotation.x
        msg.m_headRotation.z = -trackMsg.m_headRotation.y
        msg.m_headRotation.x = -trackMsg.m_headRotation.z

        msg.m_eyeGazeLeftPitch = math.radians(trackMsg.m_eyeGazeLeftPitch)
        msg.m_eyeGazeLeftYaw = math.radians(trackMsg.m_eyeGazeLeftYaw)
        msg.m_eyeGazeRightYaw = math.radians(trackMsg.m_eyeGazeRightYaw)
        msg.m_eyeGazeRightPitch = math.radians(trackMsg.m_eyeGazeRightPitch)
        # Empty m_coeffs
        msg.m_coeffs = [0] * ShapekeyStore.getLength()
        # Map by shapekeys
        fs = trackMsg.m_coeffs
        for i, sk in enumerate(ShapekeyStore.getList()):
            if sk in blend_shape_names:
                msg.m_coeffs[i] = fs[blend_shape_names.index(sk)]
        # Outer brows are same as inner
        msg.m_coeffs[5] = msg.m_coeffs[3]
        msg.m_coeffs[6] = msg.m_coeffs[4]
        msg.m_coeffs[10] = msg.m_coeffs[8]
        msg.m_coeffs[11] = msg.m_coeffs[9]

        return msg
    def map_pau(selfself, trackMsg):
        #  Final Message to be sent. Currently only m_coeffs has to be remapped
        msg = pau()
        #eyes and head remains same.
        msg.m_headRotation = copy.deepcopy(trackMsg.m_headRotation)
        # Correction
        msg.m_headRotation.y = trackMsg.m_headRotation.x
        msg.m_headRotation.z = -trackMsg.m_headRotation.y
        msg.m_headRotation.x = -trackMsg.m_headRotation.z

        
        msg.m_eyeGazeLeftPitch = math.radians(trackMsg.m_eyeGazeLeftPitch)
        msg.m_eyeGazeLeftYaw = math.radians(trackMsg.m_eyeGazeLeftYaw)
        msg.m_eyeGazeRightYaw = math.radians(trackMsg.m_eyeGazeRightYaw)
        msg.m_eyeGazeRightPitch = math.radians(trackMsg.m_eyeGazeRightPitch)
        # Empty m_coeffs
        msg.m_coeffs = [0]*ShapekeyStore.getLength()
        # Map by shapekeys
        fs = trackMsg.m_coeffs
        for i,sk in enumerate(ShapekeyStore.getList()):
            if sk in blend_shape_names:
                msg.m_coeffs[i] = fs[blend_shape_names.index(sk)]
        # Outer brows are same as inner
        msg.m_coeffs[5] = msg.m_coeffs[3]
        msg.m_coeffs[6] = msg.m_coeffs[4]
        msg.m_coeffs[10] = msg.m_coeffs[8]
        msg.m_coeffs[11] = msg.m_coeffs[9]

        return msg
 def __init__(self, args):
     self.keychains = map(
         lambda shapekey: Utils.DictKeyChain([
             "m_coeffs",
             ShapekeyStore.getIndex(shapekey)
         ]),
         args["shapekey"].split(";")
     )
Beispiel #4
0
  def handle_source(self, msg):
    if not self.confentry["enabled"]:
      return

    # Apply shapekeys
    meshname = self.confentry["binding"]["meshname"]
    for i in range(len(msg.m_coeffs)):
      shapename = ShapekeyStore.getString(i)
      bpy.data.meshes[meshname].shape_keys.key_blocks[shapename].value = msg.m_coeffs[i]

    # Process single binds
    for processor in self.singlebind_processors:
      processor(msg)
    def handle_source(self, msg):
        if not self.confentry["enabled"]:
            return

        # Apply shapekeys
        meshname = self.confentry["binding"]["meshname"]
        for i in range(len(msg.m_coeffs)):
            shapename = ShapekeyStore.getString(i)
            bpy.data.meshes[meshname].shape_keys.key_blocks[
                shapename].value = msg.m_coeffs[i]

        # Process single binds
        for processor in self.singlebind_processors:
            processor(msg)
  def _build_msg(cls, expr_entry=None):
    """
    Takes an entry from the config file and returns a constructed ROS message.
    """
    msg = fsMsgTrackingState()
    msg.m_coeffs = [0]*cls.M_COEFFS_LEN

    # Allow creation of a neutral face without an expression yaml entry.
    if expr_entry == None:
      return msg

    for shapekey in expr_entry:
      index = ShapekeyStore.getIndex(shapekey)
      if (index == None):
        rospy.logwarn("Invalid shapekey in expression data: %s", shapekey)
      else:
        msg.m_coeffs[index] = expr_entry[shapekey]
    return msg
Beispiel #7
0
    def hit(self, rms):
        """
    Publishes the current jaw-modified expression, given rms (root mean squared),
    the volume or the power of a small segment in the file.
    """

        # Map the power number to the jaw coefficient.
        # Note that coefficient can't effectively go below 0 or over 1.
        # It will be cut to this range at the receiving end (pau2motors node)
        p = self.rms_params
        jaw_coeff = min(max(math.sqrt(rms * p["scale"]), p["min"]), p["max"])

        # Copy pau expression message stored during handle_face_in(),
        # modify jaw and publish.
        cmd = copy.deepcopy(self.facepau)
        coeffs = list(cmd.m_coeffs)
        coeffs[ShapekeyStore.getIndex("JawOpen")] = jaw_coeff
        cmd.m_coeffs = coeffs
        self.pub.publish(cmd)
Beispiel #8
0
 def __init__(self, args):
     self.keychains = map(
         lambda shapekey: Utils.DictKeyChain(
             ["m_coeffs", ShapekeyStore.getIndex(shapekey)]),
         args["shapekey"].split(";"))