FTC:Controller Inputs

From Project Robotica
Jump to navigation Jump to search

In FIRST Tech Challenge the last two minutes are the driver-controlled period. During this time, the two drivers of the robot have to manipulate the controller to do certain tasks. When a team is programming the controller, they should first consider which inputs do which actions.


In Java programs such as Android Studio or onbot, teams can program the controllers by using gamepad1.<input type>. Gampad1 could also be replaced by Gamepad2. Joysticks and triggers return floating point numbers ( float), which allow for things such as moving at different speeds based on how far a joystick is moved. Buttons return true or false ( boolean). Here is a table which shows the syntax for each input and the respective input type which corresponds to the image below:


Label Input type Syntax
Axis 0 Float gamepad1.left_stick_x
Axis 1 Float (Inverted) gamepad1.left_stick_y
Axis 2 Float gamepad1.right_stick_x
Axis 3 Float (Inverted) gamepad1.right_stick_y
Button 0 Boolean gamepad1.x
Button 1 Boolean gamepad1.a
Button 2 Boolean gamepad1.b
Button 3 Boolean gamepad1.y
Button 4 Boolean gamepad1.left_bumper
Button 5 Boolean gamepad1.right_bumper
Button 6 Float gamepad1.left_trigger
Button 7 Float gamepad1.right_trigger
Button 8 Boolean gamepad1.back
Button 9 Boolean gamepad1.start
Button 10 Boolean gamepad1.left_stick_button
Button 11 Boolean gamepad1.right_stick_button
Hat 1 Boolean gamepad1.dpad_up
Hat 2 Boolean gamepad1.dpad_down
Hat 3 Boolean gamepad1.dpad_left
Hat 4 Boolean gamepad1.dpad_right

To use these inputs, teams can simply use if statements to check an input and respond accordingly. Here is an example of code that moves a motor, motor 1, when the button a is pressed and stops moving when a is no longer pressed.

if (gamepad1.a) { <br>
else {<br>

Teams can also use float inputs to do things such as control motor speed as shown below:


Blocks Programming Tool

(more info needed)

Additional Resources