PID tuner
Tune angular and lateral kP and kD from the V5 controller.
Team 38535A's tuner from their Pushback program: adjust the angular and lateral kP and kD from the controller and run a test motion with one button.
async fn driver(&mut self) {
// hold A as driver control starts to enter the tuner
if self.controller.get_digital(ControllerButton::A) {
pid_tune_mode(&mut self.controller, &self.chassis).await; // never returns
}
// ... normal driver control
}Store the controller as a ProsController (ProsController::new(peripherals.primary_controller)). It behaves like PROS's controller functions (print, clear, get_digital, get_digital_new_press), so the screen and buttons work exactly as on Pushback.
Buttons
| Button | Action |
|---|---|
| B | Switch between angular (mode 0) and lateral (mode 1) |
| Up / Down, held | kP up or down 0.1 per loop |
| Right / Left, held | kD up or down 0.1 per loop |
| Y | Reset the pose, then turn_to_heading(180, 3000) |
| X | Reset the pose, then move_to_point(0, 40, 4000) |
PID MODE: 0KP:2.60, KD:10.000.00, 0.00, 180.00
The loop prints three lines 50 ms apart and reads the buttons every 200 ms, so holding a button for one second changes a gain by 0.5.
Custom buttons and saving gains
let buttons = TuneButtons { swap_modes: ControllerButton::L1, ..TuneButtons::default() };
pid_tune_mode_with(&mut controller, &chassis, buttons).await;
// write both PIDs' gains to the SD card in Pushback's format
write_pid_values(&chassis, "pid_values.txt")?;