Reading Variables in controller.cpp file

I purchased an ODrive v3.6 56V in August for my research work and the controller works great for my project.

However, I wanted to make some changes in the control loop (PID) in position control mode and went through the firmware code available in Github. I was able to amend the controller.cpp file with my desired control loop and able to flash the customized firmware to the ODrive. It works without any physical errors. But I need to see assigned values of some variables inside the code (i.e. vel_des, pos_err) at given instances from my python script (like odrv0.axis1.controller.<variable_need_to_read>). I tried many methods, but unfortunately none of the methods worked. This may be because I’m from a mechanical engineering background and I don’t have that much knowledge on software coding.

Can someone please guide me how to read some variables in the controller.cpp file through my python script ?
(@madcowswe, @Wetmelon, @towen)
Thanks

I think you need to register your new variables in the odrive_interface.yaml file. :slight_smile:

I tried that method @towen. But still I can’t call the variable from my python script :grimacing:

Btw, I defined two new variables (pos_setpoint_p_ and vel_desired_) in the controller.cpp file and reflected in the controller.hpp file.

Thanks :hugs:

You need to compile and flash the firmware again after modifying that file… but that should be enough for it to show up

Yes, I was doing so. :grin: But didn’t work.

I found the mistake btw. I was flashing a different hex file all the time. :man_facepalming: :man_facepalming:

Thanks a lot @towen for your kind support

3 Likes