Odrive - Advanced control for parallel robot project

Hey there! You might have already heard about me from a GitHub issue. Or from my partner Gerardo Ortiz who a few weeks back asked about Odrives Control Law. Well, we, along with another 3 companions are working on a graduation project for our bachelor in Mechatronic Engineering from Tec de Monterrey campus Santa Fe here in Mexico.

We have a GitHub repo robo-control with our Matlab/Simscape simulation of our project and some Python scripts to use with the odrivetool mainly for setting up our Robot and at first executing some basic trajectories and such. At the time it is partly in Spanish (well mostly) but I’ll have to translate it all to English anyways because we are planning on publishing our research in a Journal, and to make it open source!

Our end goal is to create some form of AI or advanced algorithm that will continuously adjust the value of the controller gains to adapt to changing working situations

I already have a good start on understanding how the Odrive works but I am sure we will come across some issues where your knowledge and expertise of the ODrive inner workings will surely be very helpful for speeding up the development of our project.

For starters, we have two simple questions we would like to ask you and that we would be grateful if you could be so kind as to answer them.

  1. Our robot initial links have to be on the geometrical “0” position of our robot, aligned with the axis that runs across our two motors. For axis0 that is 410 counts ahead of its index and for the axis1 that is 710 counts ahead of the index. Given the high encoder resolution (8192 CPRs) it makes much more sense to account for this “offset” in our programming than in trying to mechanically align the axis and the offset. Is there some kind of function in the odrivetool to set our pos_setpoint to be 0 n counts after the encoder index? To account fot this offset? I see there is an odrv.axis.encoder.config.offset param? What does that parameter refer to?

  2. Can I run the liveplotter on a different instance of the odrivetool than the one I will be using to feed in real time new pos_setpoints or other commands?

Thanks for your time. I hope we can keep this channel open for continuous communication. Your help will be very much appreciated and we plan on doing a special mention of the odrive and the odrive team when publishing our paper.

Kind regards, Valentin

I think you are looking for encoder.set_linear_count() - this sets the offset up so that the encoder counts become whatever value you supply. so odrv0.axis0.encoder.set_linear_count(0) means to calibrate the zero position, without affecting the motor calibration.

As to liveplotter, I’m not sure, but some of the ODrive guys are working on a fully featured GUI to replace odrivetool. :slight_smile:

Sounds an interesting project - best of luck with it! :+1:

1 Like

Yes, please use set_linear_count to update the position value. That updates the current position to be the value specified. To get what you want, read the current position, compute the position that it should be, and then use set_linear_count when the axis is stationary to update it.

odrv.axis.encoder.config.offset is probably confusingly named, and we should probably change the name. It is an offset between the encoder position and the rotor phase, used to commutate the motor correctly. I would suggest to not change it: it is set automatically with encoder offset calibration.


Thanks @towen and @madcowswe for the tips. This new “homing” procedure ended up being really simple and a new issue #498 Homing based on encoder index only has been opened on the Odrive repo to make this procedure easily accessible to all new odrive users.

Update - the robo-control has been updated and all python code is now in English. Again, we hope that as the project moves forward this repo will help others find functions / inspiration to add to their Odrive projects.

New issues for advancing the project. We want to build a Reinforced Learning AI algorithm that will automatically adjust the controller gains for the robot to tune it to max performance. Even with changing loads, trajectories or speed requirements.

  1. How would you “measure” the mass being moved by the motors? Indirectly through the load (current) in the motor right?
    This data will be fed to a neural network so what is needed is to get a comparative value, not an absolute value.

I’ll try first to get a relation of the average measured_Iq / current_vel or something of the sort.

Any one got better ideas?