Current closed loop control, calculations and torque


For the project I am currently working, i need to create a closed-loop torque controller. I would be very interrested to know how the ODrive calculates the current. To be more precise, when I write “odrv0.axis0.motor.current_control.Iq_measured”, how does the ODrive comes up with the readings that i get.
Does the ODrive computes the power supply current to the board?
Does the ODrive calculates the current by using Clarke or Park transform on the two phases that have a shunt resistor?

Do you have any recommendations regarding the design of a torque controller?

Thank you very much in advance. :slight_smile:

Yes, exactly that

What do you mean by closed-loop torque controller? What are you using as a torque sensor?


Since there exists some sort of relationship between the torque and the current, i wish to be able to control the output torque. For example, if i wish the motor to produce a constant 1Nm torque, to obtain that i would neet to calculate the current required. In the litterature, there is mention of a torque-current constant Kt which establishes a direct proportionnal (oversimplified) relationship between torque and current (Torque = Kt * Current). Thus, my question is regarding “which current value i need to calculate so that i can compute the torque in this manner”.
The ODrives provides the following current measurement ‘’‘odrv0.axis0.motor.current_control.Iq_measured’’’, but i wanted to confirm that ‘’‘Iq_measured’’’ corresponds to the computed current based on the Park transform (d-q axis).

Thank you.

Yes, you can control the motors in torque mode with CONTROL_MODE_CURRENT_CONTROL. In fact this may at some point be renamed to CONTROL_MODE_TORQUE_CONTROL, as it’s the same thing.
The current setpoint directly controls the torque - it is the setpoint for the iq value and the torque is directly proportional to it (in the case of an ideal motor).
You don’t need to read the measured current, because the drive is already closing this loop for you.