Skip to content
Work in progress. This library and its docs are new and still changing, and some parts are not yet tested on a real robot. Something wrong or unclear?Tell us (a GitHub issue).

Tutorial 05: Drive a standard (tank) robot

You will build: a TeleOp that drives a standard (tank) robot, with a button to switch between two driving styles. The main track sets up a tank drive in one line: Drive.

You will learn: how to set up a standard drivetrain (also called tank, differential, or “skid steer”), the two ways to drive it (arcade and tank style), and how 2- and 4-motor versions differ.

You need: a standard chassis with two motors left_drive and right_drive (or four: front_left, front_right, back_left, back_right). Tutorials 01-03.

Full program: Tut05TankDrive.java Reference: drive.md: TankDrive


It has normal wheels on a left side and a right side. Both sides forward = drive forward. Left forward, right back = spin right. It cannot move sideways.

DriveConfig driveConfig = DriveConfig.tankTwoMotor(); // DriveConfig.tank() for 4 motors
driveConfig.powerLimit = 0.6;
TankDrive drive = new TankDrive(hardwareMap, driveConfig);
Your robot Config Motor names
2 motors DriveConfig.tankTwoMotor() left_drive, right_drive (same as the FTC samples)
4 motors DriveConfig.tank() front_left, front_right, back_left, back_right

With 4 motors, both motors on a side always get the same power.

The left side is reversed by default (motors on the left face the other way). Check it with MotorDirectionCheck: set its config() to DriveConfig.tankTwoMotor(), wheels off the ground, X = left, Y = right. Both must roll forward.

One stick moves forward and back, the other turns. Most new drivers find this easiest.

drive.arcade(StickShaping.shape(-gamepad1.left_stick_y, 0.05, 2),
StickShaping.shape(gamepad1.right_stick_x, 0.05, 2), speed);

The library adds and subtracts for you: left = forward + turn, right = forward - turn, scaled down together if needed so the robot keeps the curve you asked for.

Each stick drives one side, like a tank or a bulldozer. Very direct; some drivers prefer it.

drive.tank(StickShaping.shape(-gamepad1.left_stick_y, 0.05, 2),
StickShaping.shape(-gamepad1.right_stick_y, 0.05, 2), speed);

Note: BOTH sticks’ Y need the minus.

.bindToggle(Pad.G1, Btn.X,
() -> { tankStyle = true; confirm.play(true); },
() -> { tankStyle = false; confirm.play(false); })

Let each driver try both for a practice session and keep the one they drive best with.

The same as mecanum: StickShaping.slowScale(gamepad1.left_trigger, 0.3) as the last argument, and drive.stop() in finally.

AutoDrive (Tutorial 09) works on a standard drive too, but only forward/back and turns: move(24, 0, ...), move(24, 180, ...), turn(...), turnTo(...). A sideways move gives an error that says “turn first, then move”.

  1. Wheels off the ground: stick up, both sides roll forward.
  2. On the floor: arcade drives and turns as expected; right stick right = turn right.
  3. X (two buzzes): tank style. Both sticks up = forward. Left up, right down = spin right.
Problem Fix
Spins when both sides should go forward One side’s direction is wrong: flip frontLeftReversed or frontRightReversed. (With 2 motors, the library stores left_drive and right_drive as the “front” motors.)
Turns the wrong way in arcade Left and right motor names are swapped.
“TankDrive needs a TANK DriveConfig” Use DriveConfig.tank() or tankTwoMotor().
4-motor robot: one wheel fights That one motor’s direction is wrong. Use MotorDirectionCheck.
  1. Add ReverseDrive to arcade mode (Tutorial 04, section 8).
  2. Make turning gentler than driving: multiply the turn by 0.7.
  3. With 4 motors: change the config to DriveConfig.tank() and check all four with MotorDirectionCheck.

Tutorial 06: A fast, clear loop