Holding torque is low and final torque falls off in INPUT_MODE_TRAP_TRAJ

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.

image001

image002

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?

TRAP_TRAJ is fine if you’re moving the axis around, but I’d probably just use POS_FILTER or PASSTHROUGH

vel_integrator_gain = 0
pos_gain and vel_gain together set your position holding torque per distance (slope of the line)

You can enable gain scheduling to get something like the 2nd image, see ODrive API Reference — ODrive Documentation 0.6.9 documentation

I am moving the center point around quite a bit which is why I have it in TRAP_TRAJ. The project is a force feedback flight stick. The system I am emulating allows the resting position to move when the stick is trimmed. That’s why I needed the initial ramp up to be quick, but the force taper to happen over a known distance. Sorry for not mentioning this at the start.

When I was using the default POS_FILTER I was running into an issue where the stick would not have the force to move when trimmed until the stick was trimmed very far, then it would almost jump to that position instead of moving smoothly in the direction the trim was applied.

Now I have the pos_gain and vel_gain set to values that let it move when trimmed properly, but the slope ends before my travel distance.

I have not heard of PASSTHROUGH mode before. Is there any documentation on how PASSTHROUGH and gain scheduling works outside of the API? The API only states what values can be set for that mode.

On my phone so apologies for the brevity,

  1. Ensure your firmware is up to date. The behavior sounds like a bug we fixed on S1 and Pro firmware. Particularly affects low and 0 speed torque control operation
  2. Pass-through just has no filtering on pos/ve/torque inputs.
  3. Sorry, not much info on gain scheduling, it just linearly ramps the gains over a specified distance. So small movements around the trim point will have low torque and larger movements quickly ramp up in torque