Tetrix

Exercise: Using an IR Seeker

Modern Robotics has a IR beacon sensor (called IR Seeker V3) designed for use with the Tetrix control system. This sensor can detect the IR beacons used for some FTC games and provide information about the location of the beacon relative to the robot. The FTC SDK has a sample program you can use to experiment with the IR Seeker. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRIrSeeker. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK.

Exercise: Using a Color Sensor

Modern Robotics has a color sensor designed for use with the Tetrix control system. This sensor can read the color of a surface when the surface is within a few centimeters of the sensor. The FTC SDK has a sample program you can use to experiment with the color sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRColor. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK. You can copy the class to the teamcode area so any changes you make will be retained.

An Example of a Tetrix Robot Program

Here is a very simple Java program for Tetrix (FTC) robots. This is just to give you a preview of what we will be covering in the following lessons. We will show you what all of this means, where it comes from, how it works and examples of how this basic program is the basis of more complex programs that make robots move and respond to their environment. In the FTC environment, a robot program is called an OpMode.

Exercise: Drive in a Circle

Now lets look at an example that drives the robot in a circle. The key idea here is that if you drive the motors in the same direction but at different power levels (speeds) the robot will drive in an arc and if it runs long enough that arc becomes a circle. Here is the code:

Exercise: Using Encoders

So far we have been controlling the distance the robot travels with elapsed time. A more accurate way to control movement is with encoders. Encoders attach to or are integrated into the drive motors and count the revolutions of the motor shaft either optically or magnetically. The DcMotor object has support for using encoder counts to control how long the motor will run when turned on. In the example code we will run forward for 5000 encoder counts and stop. Then we will run backwards to zero encoder counts to the starting point.

Exercise: Using a Touch Sensor

Lets look a using sensors by starting with the simple touch sensor. This is simply a button that can be used to signal your code that something has happened by pushing the button. We will add a REV Robotics Touch Sensor to the robot and plug it into digital port 0-1 on the Expansion Hub. We modify our controller phone configuration to identify digital port 1 as a  Rev Touch Sensor and name it touch_sensor. Why did we use port 1 instead of 0? It has to do with the way the ports are wired.

Exercise: Using Servos

Now lets look at using servos to control robot functions. The wheel motors we used in the previous exercises simply run at whatever power level they are set at. Servos are different in that they have a defined range of motion and you control them by setting the location in that range you want the servo to move to. Once in that position, servos resist movement. Servos are typically used for arms and grippers.

Joystick Driving - Tank Mode

Exercise: Joystick Driving - Tank Mode

Now lets look at a teleop example. Here we will use the joysticks on one of the Xbox controllers to drive the robot. We will use tank style driving. In tank mode each joystick controls the motor on one side of the robot. Moving the joystick forward or backward will cause the motor on the corresponding side of the robot to turn in that direction and the power level will be determined by how much the joystick is moved off of center. In this mode, to drive straight you have to move each joystick the same amount.

Exercise: Joystick Driving - Arcade Mode

Lets look at another style of motor control (driving) called arcade. In arcade mode, a single joystick controls both forward/backward motion but also left and right. This allows the robot to be driven with one finger, typically the thumb.

Pages