For a rover with traction ESCs which must be commanded with proprietary CAN messages, what is the best approach? We are running Ardurover on Raspberry Pi.
Our initial plan is to configure ArduRover to transmit DroneCan, then, write a Python service running on the Raspberry Pi which listens to ArduRover’s DroneCan messages and translates/sends proprietary CAN messages. Not the most efficient perhaps (Ardurover will be transmitting CAN messages which are received and acted upon by another process on the same host after all) but modular and easily debuggable.
Is there a better approach? Would an ArduPilot Lua script be able to hook into an internal event or message with the commanded ESC speeds and write raw custom CAN frames efficiently? Does a LUA script even make sense given that we’re running on a Raspberry Pi?
We’d rather not maintain a custom fork of Ardurover, so we’d rather not implement in C++. But if there’s a compelling reason to, then we will.
A Lua script is almost certainly more than adequate. I wrote a rather complex CAN driver for some industrial drivers that ran at 20+ Hz very effectively. A less complex protocol would see even better performance.
Thanks for your quick response, and Happy New Year!
So LUA scripts are supported for Ardurover running on a RPi?
How best should the LUA script capture (or be notified of) the commanded ESC values for left and right motor? Should we just periodically poll each channel using get_output_pwm(output_function)?
Yes, scripting should be supported. You can check as to whether SCR_ENABLE appears in the params, but I’m fairly certain it should. You can use the SRV_Channels:get_output_scaled() binding for the left and right throttle functions (those functions may need to be assigned to unused channels for the binding to work).
Alternatively, if you wish to forego Lua and write a driver service, you can use MavLink messaging to capture throttle state at up to ~50Hz.