FIRST Robotics Competition Documents

Showing results for 
Search instead for 
Did you mean: 

Tank Drive Tutorial - LabVIEW for FRC


Tank Drive Tutorial


Question:  How do I get my robot to drive with two joysticks using tank drive?




Before you continue the steps below, you should ensure that you have identified which motor controllers and PWM lines you are going to use, as these will be needed later. Typically, in a tank drive configuration, the left joystick is used to control the left motors and the right joystick is used to control the right motors, so also make sure you know which lines/controller go to which side.


1. Open LabVIEW and double-click “FRC roboRIO Project.”

Main Screen.PNG


2. Give your project a name, add your team number, and select Arcade Drive. There are other options, but to set up this project to use tank drive, you should select this option.

3. In the Project Explorer window, open up the “Robot”

4. Press Ctrl + E to see the block diagram. It should look like the following image:

Robot Main.PNG

5. Double-click the “Teleop” VI inside of the Teleop Enabled case structure. Look at its block diagram. You will want to make two changes here:


A.  Replace the Arcade Drive VI ( with the Tank Drive VI. The new VI can be found by right-clicking on the block diagram and navigating to WPI Robotics Library >> Robot Drive >>

B.  Find the Index Array function that is after the Get You will need to create two numeric constants and wire each into one of the index inputs. You can determine what the values of each index should be by looking at the USB Devices tab in the FRC Driver Station. Move the two joysticks to determine which number (index) they are tied to. You will likely want to use the Y-axis index for each joystick. This setup lets you intuitively push up on the joysticks when you want the motors to go forward, and down when you when them to go in reverse. If you select the X-axis index for each, then you will have to move the joystick left or right (x-axis directions) to get the robot motors to move. In my setup, I’ve selected index 1 for my left motors Y-axis control and index 5 as the right motors Y-axis control. You can see the adjustments in LabVIEW in the following image:


Note: this is for the case where you have a single controller with multiple joysticks and you are referencing these axes. If you want to use two joysticks that are not on the same controller, you will need to add another joystick reference in and read from the second reference in as the second input into the Tank Drive VI.

6. Navigate back to your “Robot” and double-click on the “”

7. Confirm here that your left and right motors are connected to the same PWM lines in LabVIEW as they are on your PDP (Power Distribution Panel).

8. Confirm that the “Open 2” has the correct motor controller selected (Talon, Jaguar, Victor, etc). For example, I am using Jaguar motor controllers with my motors wired into PWM 8 and 9. The image below shows the changes I need to make:



9. Save all of the VIs that you have made adjustments to and test your robot's new tank drive!

Product Support Engineer | NI