(Raspberry Pi OS CAN protocol) Get the 2 motors python drive code

I’m using an odrive s1 board, and each board is connected to a raspberry pi 5 device using CAN HAT. I also confirmed through the file ‘can_enumerate.py’ that each board is connected. The calibration of each motor has been done with GUI. I now want to change torque and speed but I can’t find the code anywhere I look. I sacrificed 3 weeks for this. It’s really frustrating. Does anyone have the example code? Thanks in advance.

Hi! Apologies for the frusturation, CAN definitely requires some boilerplate code to get working. We’re actively working on making it easier, but for now I’d recommend checking out the code examples on the CAN guide. There’s examples there for putting the ODrive in closed loop, getting encoder feedback, sending velocity setpoints, and arbitrary parameter access.

You could also look at the botwheel explorer code: ODriveResources/botwheel-explorer/bot_ctrl.py at master · odriverobotics/ODriveResources · GitHub

Generally CAN protocols are communicated using a “.dbc” file, which can be found here. But these definitely take a bit of know-how to use, so I fully understand your frustration.

Are there any specific issues you’re having at the moment? I’d recommend starting by writing some Python to just print out received CAN messages, and send e.g. Set_Axis_State messages, then experimenting from there!

1 Like

Thank you for your quick reply. I found hope today because you shared github code!! I will test it and reply to you. Thank you very, very much.

Glad to hear we could give a bit of help! Please let me know how things go!

1 Like