Skip to main content

2 - Drivetrain

Drivetrain Typesโ€‹

Tank DriveTank Drive

Tank drive is one of the most common drivetrain configurations due to its ease of use, reliability, and minimal complexity. It works by utilizing 2 sets of wheels on each side of the robot. These wheels can be traction wheels, omni wheels, or a combination of multiple types.

  • The robot can move forward/backward by moving the wheels forward/backward
  • The robot can rotate by moving the wheels opposite of each other.
Pros โœ…Cons โŒ
- Simple
- Full power/traction
- No strafe ๐Ÿ˜ž

Example Codeโ€‹

// Define SmartMotorGroups for left and right motors
SmartMotorGroup leftMotors = SmartMotorGroup("LeftMotors", {1, -2, 3});
SmartMotorGroup rightMotors = SmartMotorGroup("RightMotors", {-4, 5, -6});

// Create a TankChassis using the defined motor groups
TankChassis chassis = TankChassis(leftMotors, rightMotors);
info

Mecanum, swerve, X-drive, and H-drive are all known as holonomic drivetrains. That is, they can move forwards, backwards, and sideways.

Controlsโ€‹

Arcade ControlsArcade Controls

Arcade controls allow the robot to be driven using a horizontal and vertical joystick input.

void opcontrol() {
while (true) {
// Move chassis based on joystick inputs
chassis.move(
mainController.leftY, // Forward/backward speed [-1.0 to 1.0]
mainController.leftX, // Turning speed [-1.0 to 1.0]
0
);

// ...
}
}

Joystick Curvingโ€‹

By default, joystick inputs are linear. This means that if you push the joystick halfway forward, the robot will move at half speed. However, this can make it difficult to control the robot at low speeds since the window for input values is very small. DevilLib includes built-in support for curving joystick inputs to give the driver more control at low speeds.

You can read more about this in the joystick curving guide.