EDIT: Disregard, made a mistake here, will update soon
Hi! So:
To oversimplify, the position controller generates a velocity setpoint, and the velocity controller generates a torque setpoint, which is then executed by the ODrive’s torque controller.
The velocity controller equation is:
Torque setpoint (Nm) = vel_error (rev/s) * vel_gain (Nm/rev/s) + ∫vel_error (rev/s * s) * vel_integrator_gain (Nm/rev/s * s)
The position controller equation is:
Velocity setpoint (rev/s) = pos_error (rev) * pos_gain (rev/s/rev)
If you set vel_integrator_gain to 0, then this simplifies to
Torque setpoint (Nm) = pos_error * pos_gain * vel_gain
Then with vel_gain == 1, this simplifies further to:
Torque setpoint (Nm) = pos_error * pos_gain
The torsional spring equation is T = k * θ, where T
is torque in Nm, k
is spring constant in Nm/radian, and θ
is angular displacement (in radian). This is exactly the same as the prior Torque setpoint (Nm) = pos_error * pos_gain
, (pos_gain == k, pos_error == θ), except with the unit of turns in radians instead of revolutions.
So e.g. if you set vel_integrator_gain to 0, vel_gain to 1, and pos_gain to 10, then in closed-loop position control with a position setpoint of 0, your system will behave as a spring with a torsional constant of 10 Nm/rev (or 2pi*10 Nm/rad)