Getting PID Gains to put in the OkapiLib Gains


In OkapiLib, in order to use the PID feature of the Chassis Controller, you need to specify gains with the withGains method in the builder.

std::shared_ptr<OdomChassisController> chassis = ChassisControllerBuilder()
    .withMotors(20, -11, -12, 19) // left motor is 1, right motor is 2 (reversed)
        {0.001, 0, 0.0001}, // Distance controller gains
        {0.001, 0, 0.0001}, // Turn controller gains
        {0.001, 0, 0.0001}  // Angle controller gains (helps drive straight)
    // green gearset, 4 inch wheel diameter, 11.5 inch wheelbase
    .withDimensions(AbstractMotor::gearset::green, {{4_in, 15.75_in}, imev5GreenTPR})
    .withOdometry() // use the same scales as the chassis (above)
    .buildOdometry(); // build an odometry chassis`

Where can I get these gains from? Or how do I measure them?

1 Like

Afaik, you tune the gains yourself with little more then trial and error.

1 Like

So do I just put random numbers until it drives the right distance & turns the right amount?

1 Like

Thats… certainly one way to do it.

But there are other and better (I think) ways to tune a PID controller: