Пример #1
0
    def set_emotion_e(self, e=0 + 0j, anim_time=-1):
        """
        Set an emotion with complex number e, within a certain time.
        """
        # Print data to log
        # print_info("Emotion; e: " + str(e) + ", time: " + str(anim_time))

        # Make sure emotion is restricted to within unity circle.
        if abs(e) > 1.0:
            e = cmath.rect(1.0, cmath.phase(e))

        self._emotion = e

        phi = cmath.phase(self._emotion)
        r = abs(self._emotion)

        Robot.apply_poly(r, phi, anim_time)
Пример #2
0
    def set_emotion_r_phi(self, r, phi, degrees=False, anim_time=-1):
        """
        Set an emotion with r and phi, within a certain time.
        """
        # Print data to log
        # print_info("Set Emotion; r: " + str(r) + ", phi: " + str(phi) +
        #            ", deg: " + str(degrees) + ", time: " + str(anim_time))

        e = 0 + 0j
        # Emotion from r and phi
        if r is None or phi is None:
            raise RuntimeError(
                "Bad combination of parameters; r and phi need to be provided."
            )

        if degrees:
            phi = phi * math.pi / 180.0

        phi = constrain(phi, 0.0, 2 * math.pi)
        r = constrain(r, 0.0, 1.0)

        Robot.apply_poly(r, phi, anim_time)
Пример #3
0
    def set_emotion_index(self, index, anim_time=-1):
        """
        Set an emotion with index in defined expression list, within a certain time.
        """

        e = 0 + 0j
        # Emotion from list
        if index is None:
            raise RuntimeError(
                "Bad combination of parameters; index needs to be provided.")

        index = constrain(index, 0, len(self.expressions) - 1)

        exp = self.expressions[index]

        if 'poly' in exp:
            # 20 values in poly, (poly * 2*pi/20)
            phi = constrain(exp['poly'] * math.pi / 10, 0.0, 2 * math.pi)
            Robot.apply_poly(1.0, phi, anim_time)

        if 'dofs' in exp:
            # send dofs directly to the robot
            Robot.set_dof_list(exp['dofs'], anim_time)