Using a Gamepad

Using Gamepads

While our robot is able to do a lot autonomously, more often than not we need to input commands using our connected gamepad. There is a large variety of gamepads that could be used with the Driver Hub. For this tutorial we will be focusing on a generic PS4 controller, such as the Etpark Wired Controller or a Logitech controller.

To initialize the gamepad that will act as User 1 (gamepad1, in code) press the options button and the Cross/A button on the gamepad at the same time. To initialize User 2 ( gamepad2, in code) press the options button and the Circle/B button at the same time.

All buttons on a gamepad can be programmed to a specific task or behavior. Let's take a look at the breakdown of each button, their associated block name, and the type of data they output:

Boolean vs Float Data Types

The gamepad outputs two types of data back to the Control Hub to be used within the program:

Boolean

Boolean data has two possible values: True and False. These two values can also be represented by On and Off or 1 and 0.

The buttons, bumpers, and triggers on the gamepad provide boolean data to our robot! For example, a button that is not pressed will return a value of False (or 0) and a button that is pressed will return the value True (or 1).

Float

Float data is a number that can include decimal places and positive or negative values.

On the gamepad, the float data returned will be between 1 and -1 for the joystick's position on each axis. Some examples of possible values are 0.44, 0, -0.29, or -1.

Last updated