Tuning the Controller
Tuning the motor controller is an essential step to unlock the full potential of the ODrive. Tuning allows for the controller to quickly respond to disturbances or changes in the system (such as an external force being applied or a change in the setpoint) without becoming unstable.
- An upcoming feature will enable automatic tuning. Until then, here is a rough tuning procedure:
Use the Dashboard tab in the GUI.
Set vel_integrator_gain gain to 0. Set the system to control velocity mode, or if continuous rotation is impractical, keep position control mode and reduce the position gain to the lowest practicable value.
Make sure you have a stable system. If it is not, decrease all vel_gain until you have one.
Increase
vel_gain
by around 30% per iteration until the motor exhibits some vibration. Try sending some commands to excite the system. You can also apply an external disturbance if safe to do so.Back down
vel_gain
to 50% of the vibrating value.(if using position control mode) Increase
pos_gain
by around 30% per iteration until you see some overshoot on command steps.(if using position control mode) Back down
pos_gain
until you do not have overshoot anymore.Turn up integrator gain until velocity setpoint changes or disturbances get underdamped (overshoot), then turn it down to about 50% of that. If using position control mode, both the pos_gain and the vel_integrator_gain is limited by overshoot, and may need to be tuned against each other. A good starting point for vel_integrator_gain is to use the same value as the vel_gain.
The liveplotter tool can also be helpful in place of the GUI. To display a graph that plots the position setpoint vs the measured position value run the following in the ODrive tool:
start_liveplotter(lambda:[odrv0.axis0.pos_estimate, odrv0.axis0.controller.pos_setpoint])
Other Parameters to Tweak
Advanced users may consider also tuning the following:
odrv0.axis0.controller.config.vel_integrator_limit
odrv0.axis0.config.encoder_bandwidth
odrv0.axis0.config.motor.current_slew_rate_limit
odrv0.axis0.config.motor.current_control_bandwidth