max_velocity_slip with moteus
The moteus brushless motor controller supports several concepts of operation from within its primary “position” mode, including a velocity mode. As documented in the reference, you can run in that scenario using commands equivalent to the diagnostic mode command:
d pos nan V nan
Where V is the desired velocity. However, as with most control operations, there are a number of edge cases that can be useful to handle. When operating purely in velocity mode, the normal PID constants can be interpreted slightly differently:
-
servo.pid_position.kd
- this is effectively the proportional constant in velocity control -
servo.pid_position.kp
- this is effectively the integrative constant in velocity control -
servo.max_position_slip
- this is the “anti-windup” term for the integral term
If an external torque is applied that exceeds the maximum torque that the system is capable of generating for an extended period of time, then undesired transients can emerge. In that case, the actual velocity can diverge arbitrarily from the commanded velocity. For instance, if a drag force were applied that exceeded the maximum commanded torque, the system could stop. If that external force is released, then there is a large discrepancy between the actual and commanded velocity, which results in a non-ideal transient response that may overshoot or oscillate.
The normal mechanism to enforce a slew rate for the commanded velocity in moteus is to use the trajectory velocity limit, either through configuration with servo.accel_limit
, or by specifying a per-command acceleration limit. That limits the rate of change in velocity command, but does nothing in the case where an external force causes the controller to diverge.
As of release 2024-01-06, moteus now supports a new configuration option to help resolve this:
servo.max_velocity_slip
Like servo.max_position_slip
, this limits the amount that the control velocity can diverge from the measured velocity. If set appropriately, it will result in a motor using the configured acceleration limit if an external torque is released, rather than attempting to instantaneously restore the commanded velocity. Selecting the value for this configuration does require some care. It must be significantly larger than the expected noise in velocity measurements, yet small enough to result in an effective clamping during expected transients.
The following plot shows an instance where an external torque causes the actual velocity to temporarily drop to 0. The left plots demonstrate what will happen if servo.max_velocity_slip
is “NaN”, i.e. disabled, and the right plots show what will happen if it is set to 2 Hz. As can be seen, limiting the delta between the control and actual velocity can result in decreased overshoot or otherwise undesired transients when external torques are released.
This video gives a quick demonstration of the with and without as well.