Пример #1
0
    def default_action(self):
        """ Run attitude controller and apply resulting force and torque to the parent robot. """
        # Get the the parent robot
        robot = self.robot_parent

        engines_input = Vector(self.local_data['engines'])
        engines_input_sq = Vector.Fill(len(engines_input), 0.0)
        for i in range(0, len(engines_input)):
            engines_input_sq[i] = engines_input[i] * engines_input[i]
        moment_vector = self.transformation * engines_input_sq

        logger.debug("%s => %s" % (engines_input, moment_vector))

        force = (0.0, 0.0, moment_vector[0])
        torque = (moment_vector[1], moment_vector[2], moment_vector[3])

        # directly apply local forces and torques to the blender object of the parent robot
        robot.bge_object.applyForce(force, True)
        robot.bge_object.applyTorque(torque, True)