Sending CANSimple velocity commands from PWM values

We are planning to use PWM values of servo functions THROTTLE (70) and GROUNDSTEERING (26) calculated by Ardupilot, scale it down, make it to valid velocity commands and send it out to ODrive motor drivers on the CAN bus.

Yesterday we tested that my theory is working in practice, we have sent out PWM values of throttle between 1000 and 2000 and the wheels actually moved thanks to our custom Lua script sending valid CANSimple-messages to the CAN-bus the ODrives are connected to.

We have not used this technique for autonomous navigation, yet, but the results are so good that we want to proceed further.

Now in Mission Planner we could tune throttle and steering, I know that, but would it change the way PWM values are calculated during the autonomous navigation? My question is that should we bother with copying the PID values the ODrive motor controller is tuned or leave it as it is? So the PWM values would be calculated in autonomous mode as we expect.

Why not move to autopilot hardware that supports can directly? Many ardupilot compatible autopilots have native can support. Simply run wires (canh and canl) from the autopilot to the speed controllers. I think this is safer and more reliable than PWM… We’re using Pixhawk 6C and driving speed controllers (we’re using vescs) using CAN.

1 Like

Okay, we’ll think about that when we get there, thank you. Right now the setup is with ODrive modules, we have manual control over the vehicle, and now we are moving to autonomous control. For this my best guess was to fetch velocity commands from PWM values. The output however is sent to the drivers on the CAN bus.