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. If something is wrong or unclear,tell us with a short GitHub form.

Tutorial 05: Drive a standard (tank) robot

In the five files, one line in Robot.java sets up a tank drive: A tank drive instead. Build it by hand here with TankDrive to see the two driving styles inside.

You will build: a TeleOp that drives a standard (tank) robot, with a button to switch between two driving styles.

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

Full program: Tut05TankDrive.java


A standard drive (also called tank, differential, or “skid steer”) 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

powerLimit = 0.6 keeps every wheel at 60% or less while you test. With 4 motors, both motors on a side always get the same power.

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

One stick moves forward and back, and the other turns. For most new drivers, this style is the 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. When a side goes past full power, the library scales both sides down together, so the robot keeps the curve you asked for.

Each stick drives one side, like a bulldozer. It is very direct, and some drivers like it better. BOTH sticks’ Y need the minus.

drive.tank(StickShaping.shape(-gamepad1.left_stick_y, 0.05, 2),
StickShaping.shape(-gamepad1.right_stick_y, 0.05, 2), speed);
.bindToggle(Pad.G1, Btn.X,
() -> { tankStyle = true; confirm.play(true); },
() -> { tankStyle = false; confirm.play(false); })

Let each driver try both styles for a practice session. Keep the one they drive best with. Slow mode and drive.stop() in finally work the same as on mecanum.

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. With the wheels off the ground, push the stick up: both sides roll forward.
  2. On the floor, arcade style 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 the others That one motor’s direction is wrong. Use MotorDirectionCheck.
  1. Add ReverseDrive to arcade mode (Tutorial 04).
  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.

Next: Tutorial 06: A fast, clear loop. Look it up: drive.md: TankDrive, gamepad.md.

Something wrong on this page? Tell us with a short GitHub form.