Is this a way to measure torque?

This is my code:

axis.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
axis.controller.config.input_mode = INPUT_MODE_PASSTHROUGH
axis.controller.input_torque = 1
power = axis.controller.mechanical_power # (Nm * rad/s)
vel_rad_s = axis.encoder.vel_estimate * 6.28318 # convert rev/s in rad/s
torque = power / vel_rad_s
print(“Measured torque:”, torque, “Nm”)
axis.requested_state = AXIS_STATE_IDLE

The result of this (if it is a good way) should be 1, but instead I am receiving 0.038.
Some help please

HI there,

You can measure torque by multiplying Iq_measured with the torque_constant.

axis.controller.input_torque = 1
iq_measured = axis.motor.current_control.Iq_measured
torque = iq_measured * axis.motor.config.torque_constant
print(“Measured torque:”, torque, “Nm”)
axis.requested_state = AXIS_STATE_IDLE

The resulting torque is always very low, between 0.01 and 0.05

What motor are you using? 1Nm is quite a bit, and your motor may not be able to achieve this - or your current limit may be set too low.

I am using D5065 270KV and my current limit is 15A.
¿The result of torque = iq_measured * axis.motor.config.torque_constant is expressed in N*m?

Correct, Nm

Note this in the docs: Controller — ODrive Documentation 0.6.9 documentation

You may need to increase the vel_gain, vel_limit, or disable enable_torque_mode_vel_limit (which can be dangerous - careful).

Is your torque constant set as 0.0306 or so?

my torque constant is exactly that number

Can you check torque_setpoint when you give that 1Nm command?

Is the motor spinning up to max speed, or is the rotor locked?

axis.controller.torque_setpoint shows the same value as the one I declare in axis.controller.input_torque

The motor is spinning up to 20 rps with is the max speed I declared

If I do this: axis.controller.config.enable_torque_mode_vel_limit = False
I get this error:

Can you run dump_errors(odrv0)?


Well yes, it’s overspeed now that you’ve disabled the velocity limit :stuck_out_tongue:

You should probably keep enable_torque_mode_vel_limit set to True and instead increase vel_gai/vel_limit.

I set the vel_limit in 30 and the vel_gain in 0.25 and the resulting torque never reaches even 0.1 Nm

Can you run odrivetool backup-config config.json then upload config.json somewhere and share the link here?

Yes! Thanks for your interest.