Driver Control
Odyssey provides three drive schemes plus input shaping. All of them go in
opcontrol():
void opcontrol() {
while (true) {
const int throttle = master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
const int turn = master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
chassis.arcade(throttle, turn);
pros::delay(20);
}
}
Drive schemes
Tank
Each stick controls one side directly.
chassis.tank(master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y),
master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));
Arcade
One input for speed, one for turn rate. Simple and predictable.
Curvature
Like arcade, but the turn stick controls the curvature of the arc rather than the turn rate. The same stick deflection produces the same shaped arc whether you are creeping or at full speed, which most drivers find more natural once they adjust. At zero throttle it falls back to spinning in place.
Input curves
An ExpoDriveCurve reshapes stick input for finer control:
// deadband, minOutput, curve
odyssey::ExpoDriveCurve throttleCurve(3, 10, 1.019);
odyssey::ExpoDriveCurve steerCurve(3, 10, 1.019);
odyssey::Chassis chassis(drivetrain, lateralSettings, angularSettings, sensors,
&throttleCurve, &steerCurve);
- deadband — inputs below this are ignored. Fixes joysticks that don't quite return to zero (3-5 is typical).
- minOutput — the smallest output once you leave the deadband. Set it just high enough that the robot actually creeps instead of humming (8-12 is typical).
- curve — the exponential gain.
1is linear.1.01-1.05makes the center of the stick progressively gentler while full deflection stays at full power. Try1.019and adjust to driver taste.
Pass true as the third argument of any drive function to bypass the curves
temporarily:
Brake mode
chassis.setBrakeMode(pros::E_MOTOR_BRAKE_COAST); // default, easiest on motors
chassis.setBrakeMode(pros::E_MOTOR_BRAKE_BRAKE); // stops faster
chassis.setBrakeMode(pros::E_MOTOR_BRAKE_HOLD); // actively holds position
A common pattern is HOLD while climbing or defending and COAST otherwise,
toggled on a controller button.