1. Gamepad controls and programming

Introduction to Tetrix GamePad control programming

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. 

FTC Push Bot Chassis from Tetrix

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.

Connect Tetrix Gamepads to the Motorola phones

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.

Connection

  1. Connect the GamePads to the hub.
  2. Start FTC App on the android phone
  3. 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.
  4. Verify that there is a small icon at the top of the screen of the Android phone.

Make sure Gamepad is recognized by the phone

The icon that a Gamepad is connected should be visible in FTC application running on the phone.

Simple program for moving the robot with the gamepads

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.

 

Simple Calm Op Mode for the FTC Tetrix Push Bot Robot Arm

When lowering the arm it is important not to hit the robot. This is a simple program for controlling the speed of lowering the arm. It uses the distance sensor.

Download and run the code

Download and run the code for simple moving with the robot. You have the op mode code that you could directly copy/paste or following the video re-write.

Tetrix Gamepads. Controlling the motors with only one Gamepad Stick.

Tetrix Gamepads. Controlling the motors with two separate GamePad Sticks

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.