Ejemplo n.º 1
0
def robot_dofs_data():
    dof_values = request.form.get('dofdata', type=str, default=None)

    # dof_values = request.form.get('values', type=str, default='')
    # print(dof_values)
    if dof_values is not None:
        dof_values = yaml.load(dof_values, Loader=Loader)
        if type(dof_values) is dict:
            Robot.set_dof_values(dof_values)
        elif type(dof_values) is list:
            Robot.set_dof_list(dof_values)

    tempDofs = Robot.get_dof_values()
    return json.dumps({'success': True, 'dofs': tempDofs})
Ejemplo n.º 2
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)