We start with FIRST Technical Challenge and how you develop programs with the GamePads. It is up to you to decide how sticks, buttons and triggers from the GamePad will control the different motors of the robot and there are different decisions that you should make.
This is the chassis for the popular FTC Push Bot. The robot is built with the Tetrix set and uses two motors. When preparing for a FIRST Technical Challenge competition (FTC) it is very useful to have a chassis from which you could start working. It might not, and will surely not be the final robot, but a good base is always useful.
With this chassis, we've also made a short course of how to control it. Take a look at FIRST Technical Challenge. Basic GamePads, control and attachments for the Tetrix set.
In this tutorial, we connect the Motorola phones to the Tetrix controller using the USB hub.
The USB hub comes with the kit. The phones also come with the kit. The gamepads also come with the kit.
- Connect the GamePads to the hub.
- Start FTC App on the android phone
- On the GamePad press the start button and "A" at the same time. This will connect the GamePad to the phone. Do not press the start button and then "A". Press them in the same time.
- Verify that there is a small icon at the top of the screen of the Android phone.
In this tutorial, we would build a simple program for controlling the Tetrix robot motors with the GamePads. We use the stick and when the stick is pushed forward the motors move forward. When it is pushed backwards the robot moves backwards.
The phones are connected
For this tutorial, I would assume that the phones are already connected to each other. If you have any problem connecting them then write us in the comments section and we would try to help you.
Control with the stick
The program that we are developing controls the motors. If you push or pull the stick this will rotate the wheels. If you slightly push or pull the stick than this will slightly rotate the wheels. We are directly setting the power of the motors based on the push/pull of the stick.
In this tutorial, we are controlling the FTC Tetrix robot with the two sticks of the same GamePad. The left stick is for forward and backwards, while the right stick is for left and right.
Different power for the left and right motor
The calculation should be done based on the position of the stick. We take the account for the "x" and "y" position of both sticks. 50% of the power should come from the left and 50% from the right stick.
leftPower = - gamepad1.left_stick_y/2 + gamepad1.right_stick_x/2
leftPower = - gamepad1.left_stick_y/2 - gamepad1.right_stick_x/2
Part of the power comes from the Y axis of the first stick and part of the X axis from the second stick. You can modify the formula, but the principle for controlling with both sticks is the same.