I am trying to use an ODrive to develop a mechanism that returns to a center point and increases torque based on the distance from center. I need the ODrive to hold the position I give it, and the travel distance is limited to about ¼ of a motor turn. I have an ODrive Pro running 0.6.9 controlling the ODrive D6374 150KV motor with an RS485 encoder.
Right now I have found that the only mode which can hold the position as accurately as I want is the TRAP_TRAJ
input mode. While TRAP_TRAJ
is getting the job done for now, the holding torque doesn’t ramp up as quickly as I’d like, and it tapers off too quickly. This is creating a situation where there is “slop” towards the center, and a constant torque near the end of travel, which to the human hand feels like a taper off/less force.
Below I have two graphs showing torque over distance where the first one is what I am currently experiencing, and the second one is more similar to the behavior I would like the system to have. I am using an ambiguous (-1,1) distance range where 0 is the resting position, and again an ambiguous (0,1) torque value for the output torque of the system.
Below are my settings for the drive:
odrv0.axis0.config.torque_soft_max = 3
odrv0.axis0.config.torque_soft_min = -3
odrv0.axis0.controller.config.pos_gain = 60
odrv0.axis0.controller.config.vel_gain = .8
odrv0.axis0.controller.config.vel_integrator_gain = 0
odrv0.config.dc_max_positive_current = 12.8
odrv0.config.dc_max_negative_current = -8
odrv0.axis0.config.motor.current_soft_max = 70
odrv0.axis0.config.motor.current_hard_max = 90
odrv0.axis0.controller.config.vel_limit = 100
odrv0.axis0.controller.config.spinout_electrical_power_threshold = 100
odrv0.axis0.controller.config.spinout_mechanical_power_threshold = -100
odrv0.config.gpio1_mode = GpioMode.DIGITAL_PULL_UP
odrv0.config.gpio2_mode = GpioMode.DIGITAL_PULL_UP
odrv0.axis0.controller.config.input_mode = INPUT_MODE_TRAP_TRAJ
I cannot add an integrator because there are times when the system will be held away from zero. Adding an integrator caused unstable results. Changing pos_gain
and vel_gain
seem to be the documented way of controlling this behavior, however, changing these values seems to change the torque output, but not the distance at which the torque is increased.
Is there a way to control the response like I showed comparing the two graphs, or is the closed loop controller doing that math under the hood and I have no control of what it does?