Save offset angle from set_linear_count()

Is it possible to make the angular offset applied by odrv0.axis0.encoder.set_linear_count(0) persist after rebooting? Also: is it possible to read this offset value after it’s been applied?

I have a robot “leg” setup with absolute encoders (AMS5048A) on the joints. I’d like to move the joints into a “default,” “zero” position, and then save that position as the “zero” position across reboots. Currently, the way I’d have to do this is to store that offset in some wrapper code to control the leg, but I feel like there should be a way to do this with the ODrive configs.

Any thoughts would be super helpful. Thanks!

Hmm, good question. We have sorta this type of thing for index_offset… but it won’t work for absolute encoders. Let me ask the rest of the team about this, I may be forgetting something. You can of course set the AS5048A zero position via SPI from another controller if you want

That’d be grand. For now I have a wrapper class in Python where I can just call set_linear_count(0) on each joint with the robot leg in a “calibration” position. But it would be great to take advantage of the encoder’s absoluteness and the ODrive’s stored config by having the ODrive store this offset onboard.

Well you don’t actually have to move the axis to the calibration position. If you know the offset, you can just set set_linear_count((pos_estimate + offset) * cpr) or similar.

1 Like