Exemplo n.º 1
0
 def update_controls(self, controls: PlayerInput):
     air_roll = self.button_data[2] or self.button_data[9]
     controls.throttle = self.axis_data[5] - self.axis_data[4]
     controls.steer = self.axis_data[0]
     controls.pitch = self.axis_data[1]
     controls.yaw = 0 if air_roll else self.axis_data[0]
     controls.roll = self.axis_data[0] if air_roll else 0
     controls.jump = self.button_data[0]
     controls.boost = self.button_data[1]
     controls.handbrake = air_roll
Exemplo n.º 2
0
 def get_player_input(self) -> PlayerInput:
     player_input = PlayerInput()
     player_input.throttle = self.controls.throttle
     player_input.steer = self.controls.steer
     player_input.pitch = self.controls.pitch
     player_input.yaw = self.controls.yaw
     player_input.roll = self.controls.roll
     player_input.jump = self.controls.jump
     player_input.boost = self.controls.boost
     player_input.handbrake = self.controls.handbrake
     return player_input
Exemplo n.º 3
0
def convert_player_input(ctrl: SimpleControllerState) -> PlayerInput:
    """
    Converts a SimpleControllerState to a PlayerInput object.
    """
    player_input = PlayerInput()
    player_input.throttle = ctrl.throttle
    player_input.steer = ctrl.steer
    player_input.pitch = ctrl.pitch
    player_input.yaw = ctrl.yaw
    player_input.roll = ctrl.roll
    player_input.jump = ctrl.jump
    player_input.boost = ctrl.boost
    player_input.handbrake = ctrl.handbrake
    player_input.use_item = ctrl.use_item
    return player_input
Exemplo n.º 4
0
    def get_player_input(self) -> PlayerInput:
        """"Get the current controls from the drone.

        :return: Current controls for this car.
        :rtype: PlayerInput
        """

        # Throw error if no controls were set.
        if self.controller is None:
            RuntimeError(f"Did not set the controls for drone {self.index}")

        # PlayerInput mapping
        player_input = PlayerInput()
        player_input.throttle = self.controller.throttle  # -1 for full reverse, 1 for full forward
        player_input.steer = self.controller.steer  # -1 for full left, 1 for full right
        player_input.pitch = self.controller.pitch  # -1 for nose down, 1 for nose up
        player_input.yaw = self.controller.yaw  # -1 for full left, 1 for full right
        player_input.roll = self.controller.roll  # -1 for roll left, 1 for roll right
        player_input.jump = self.controller.jump  # true if you want to press the jump button
        player_input.boost = self.controller.boost  # true if you want to press the boost button
        player_input.handbrake = self.controller.handbrake  # true if you want to press the handbrake button
        return player_input