So I want to do a simple constant torque on a motor through torque mode, but the motor is not moving when inputting a torque value, although it calibrates well, and the .current_state
sends a value of 8
showing it’s in closed loop indeed. The code is as below:
import odrive
from odrive.enums import *
import time
#Find a connected ODrive (this will block until you connect one)
print("finding an odrive...")
odrv0 = odrive.find_any(serial_number=SERIAL_NUM)
#Set initial conditions
odrv0.clear_errors()
#Calibrate motor and wait for it to finish
print("starting calibration...")
odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
odrv0.axis1.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
#wait until we finish calibraiton
while odrv0.axis0.current_state != AXIS_STATE_IDLE:
time.sleep(0.1)
#Set all motors to Closed Loop Control State
odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
#Set all motors to Torque Loop Control Mode
odrv0.axis0.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
odrv0.axis1.controller.config.control_mode = CONTROL_MODE_TORQUE_CONTROL
#Set torque of each motor
odrv0.axis0.controller.input_torque = -0.1
odrv0.axis1.controller.input_torque = 0.1
I even tried to set a torque_constant = 8.23 / 270
as I use the D5065 - 270kv motor, but still no use. I tried different torque values too, but it didn’t work. Am I missing something?