Arcade Drive Example
- Java
- C++
What This Example Demonstrates
DifferentialDrive Class
TheDifferentialDrive class provides several drive modes:
Arcade Drive:
xSpeed: Forward/backward speed (-1.0 to 1.0)zRotation: Rotation speed (-1.0 to 1.0)- Third parameter (optional): Enable input squaring for finer control at low speeds
- Direct control of left and right sides
- Good for drivers familiar with tank-style controls
- More like car steering
isQuickTurn: When true, enables turning in place
Input Squaring
By default,arcadeDrive() squares inputs while preserving sign:
- Finer control at low speeds
- More aggressive response at high speeds
Motor Inversion
For a differential drive, motors face opposite directions. Invert one side so positive values drive both forward:Joystick Negation
Joysticks return negative values when pushed forward (up). Negate to make forward motion intuitive:Running in Simulation
- Open the robot simulator
- Enable teleoperated mode
- Use a joystick:
- Y-axis (forward/back): Push forward to drive forward
- X-axis (left/right): Push left to turn left
Related Examples
- Tank Drive: Two-stick control for differential drives
- Mecanum Drive: Omnidirectional driving with mecanum wheels
- Swerve Drive: Independent module steering and driving
Source Location
- Java:
wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/arcadedrive/Robot.java - C++:
wpilibcExamples/src/main/cpp/examples/ArcadeDrive/cpp/Robot.cpp