Custom current control loop

If I were to want to build my own control loop, would it be feasible to do this on an arduino that is connected to the ODrive via a CANBus? Or is the right thing to actually modify the firmware and flash it onto the chip?

I would want the externally implemented control loop to run at an extremely high frequency. One option I was considering is putting the ODrive into torque control mode, and having the external system set the input_torque. Would this work well / is practical? How fast an update frequency can be accomplished this way?

Depends on what kind of communication protocol you use, how many ODrives you want to communicate with and how much information you want to receive/send.
In my project, I’m using UART with 2 ODrives with a Jetson Nano and I’m at about 100Hz. That probably wouldn’t be enough for a current control loop.

Hi! There shouldn’t be any issue whatsoever doing this, and it’s quite common in dynamic and legged robotics. Using an external torque setpoint is likely the right move. With an optimized CAN communication implementation, it should be possible to get ~1-2kHz control loop frequency.

Thanks, this is super helpful.
Are there any protocols faster than CAN that be used between an arduino and the odrive? (2khz is probably enough, but just wondering.) For instance, the usb or serial protocols? Can I run a control loop on a linux pc communicating via usb?

The other question I have is how to use the torque control loop but make it a little safer. I would like to have the odrive internally enforce some constraints like:

  1. If position outside some range, set torque to 0
  2. If vel above some range, set torque to zero (I think I can do this by setting vel_limit?)

Is there a way to dump the entire state of the controller, like all the variables, in some json, so I can ensure I have set all of them in the right way to accomplish the goal?