Skip to content

How to tune the PID controllers

ahoarau edited this page Nov 6, 2014 · 3 revisions

M3 Joint Tuning Tool

Tuning the PID controllers is a very easy process using the joint tuning tool. It will help you set gains and send commands to the robot so you can see the modifications in realtime.

Note: it works by modifying the Param protobuf attached to each component to the realtime server.

Launch the GUI:

m3dev_joint_tuning.py

Tuning PID controllers: general information

Check out PID without a PHD.

Basically what we need on the robot is fast responsiveness and no overshoot, otherwise it will bump into objects to gasps for example. As velocities are quite noisy, the 'D' parameter of a PID should not be set very high. As a rule of thumb, I start by setting 'I' and 'D' to zero, tuning 'P' until it shakes, lower it a bit, then start playing with the 'D' term for a nice behavior (like a slow arrival). Eventually, the 'I' term is set to cancel static error.

Note: In most cases, the 'D' term is 0 or very low.

Warning : The robot might shake if the PID gains are set too high. This can cause hardware issues, so keep the red button in hand at all time when tuning the PIDs.

Tuning Torque Control PID

Torque is the lowest level from which the other modes derives, so if torque mode works perfectly, then the other modes (theta, thetadot) will work even better.

Set the actuator mode to torque (no GC), set a torque cmd (like 1600 mNm), and see how is reacts.

Then the parameters are in the ctrl_simple component attached to each actuator, under pid_torque. Just set a value and press Enter to send it to the robot. It's as easy as that.

When you're done, you can press save to save the config file.

Note: Arm motors can be quite precise and fast (no overshoot and fast responsiveness), so unless PID torque torque is perfect, don't save it.

Note: Thanks to overlays, you copy all the real_robot content in a different location and overlay the config files so the original configuration of the robot remains unchanged.

Tuning Position Control PID

Same as above, put the actuator in theta mode, then tune the pid in ctrl_simple, pid_theta.

Warning: if you improve the torque mode, then the theta mode will probably become unstable, because the previous gains are now too high for the robot. Usually you'll have to lower them (and that's a nice feature in the end because low gains means more compliance !).

Note: If you tune it well, you can achieve a ~0.1 degrees accuracy.

Tuning Velocity Control PID

PID parameters for the velocity controller are directly in the joint component of the actuator.

The names of the parameters are:

kqdot_d: 0.0
kqdot_i: 0.0
kqdot_i_limit: 1000.0
kqdot_i_range: 1500.0
kqdot_p: -100.0

Note: as of October 2014, only right_arm has been calibrated for velocity control

Note to dev: these parameters can be switched to the **ctrl_simple component by added a command mode in ctrl_simple.cpp and updating the command mode in joint.cpp