Set output encoder zero position

I’m using ODrive 3.6/0.5.6, with a motor with a second absolute encoder on the gearbox’s output shaft. Is there a way to reset where ODrive thinks the zero position is? I’m creating a robot with many of these motors, and I’d love them all to go to the same position when setting input_pos=0. Otherwise, I feel like I’d need to save the zero position offset in the program that drives the motors.

Hmm, honestly not sure if that’s supported on v3.6/0.5.6. You may have to manually call set_linear_count from your program with the zero position offset, yes.

When I call set_linear_count with the offset, it moves the motor to that position. For reference, how would I do this on the latest version of odrive?

When I call set_linear_count with the offset, it moves the motor to that position

Hmm, yes I think this is because the input_pos is staying the same, but the encoder position is changing. You’d have to also set input_pos to zero at the same time.

For reference, how would I do this on the latest version of odrive?

On ODrive Pro, S1, or Micro you’d just use the absolute encoder reference frame, and the ODrive would automatically initialize the position based on the encoder’s absolute position.

1 Like

I think I figured it out:

To set the current position as the zero position:

odrv0.axis0.encoder.config.index_offset=odrv0.axis0.encoder.pos_estimate
odrv0.save_configuration()

The motor has to save & reboot before input_pos = 0 will return to that position.

It also looks like set_linear_count() does work if it’s set when the motor is idle. However, this value isn’t retained when the controller looses power.

That should do it.