How to convert input_torque to force

I’m having trouble to find a way to convert the torque I input into Odrive to the real-life torque and force, due to the effects of controller.config.vel_limit. I’m using D5065 motor, I have set the torque constant to 8.23/270 as per the guide. However, the output torque is highly affected by the vel_limit for some reason. Like if I input 0.5 as input_torque with a vel_limit of 1, I’m having 0.5 Kg of force on my 50mm radius pulley. But when I keep the same torque value, and increase the vel_limit to 1 or higher, I’m getting 1 Kg, or even 3+ Kg at vel_limit of 2.

How should I set the vel_limit so the input torque matches the output torque real-life, without making the motor goes insanely fast as I’m having a high weight on it. Theoretically speaking the motor should have higher torque on lower velocities correct?

a snippet of the code is below:

vel_lim = 0.5


odrv0.axis0.controller.config.vel_limit = vel_lim + (vel_lim*0.5)
odrv0.axis1.controller.config.vel_limit = vel_lim + (vel_lim*0.5)
odrv1.axis0.controller.config.vel_limit = vel_lim + (vel_lim*0.5)
odrv1.axis1.controller.config.vel_limit = vel_lim + (vel_lim*0.5)

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv1.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv1.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

odrv0.axis0.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
odrv0.axis1.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
odrv1.axis0.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
odrv1.axis1.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL

odrv0.axis0.controller.config.input_mode = INPUT_MODE_PASSTHROUGH
odrv0.axis1.controller.config.input_mode = INPUT_MODE_PASSTHROUGH
odrv1.axis0.controller.config.input_mode = INPUT_MODE_PASSTHROUGH
odrv1.axis1.controller.config.input_mode = INPUT_MODE_PASSTHROUGH


torque_const = 8.23 / 270

odrv0.axis0.motor.config.torque_constant = torque_const
odrv0.axis1.motor.config.torque_constant = torque_const
odrv1.axis0.motor.config.torque_constant = torque_const
odrv1.axis1.motor.config.torque_constant = torque_const

#Set torque of each motor
tor = 0.05
odrv0.axis0.controller.input_torque = tor
odrv0.axis1.controller.input_torque = tor 
odrv1.axis0.controller.input_torque = tor
odrv1.axis1.controller.input_torque = tor

Hi there - this is documented in the latest docs here: Controller — ODrive Documentation 0.6.8 documentation

Hasn’t been ported back to v3.6 docs, apologies.

Essentially - vel_gain is used to ramp down torque as the motor approaches vel_limit. Increasing vel_gain will decrease the margin to vel_limit at which the motor starts to ramp down torque. The default values of vel_gain typically result in torque being limited even at zero speed.

This may seem weird, but enforcing a vel_limit on torque is very similar to a proportional velocity controller, so a well-tuned vel_gain will result in proper, stable torque limiting as the ODrive approaches vel_limit.

So I need to increase the vel_gain, so I have more torque with less velocity?

Correct. Ideally you’d actually tune the vel_gain in velocity control mode, but you can probably just increase it now and then decrease it later if there’s oscillation when approaching your vel_limit.

1 Like

Alright, thanks a lot @solomondg I will test that.