I am attempting to use a Lua script to interpret fields from a MANUAL_CONTROL message, but it appears that there isn’t a built-in binding to parse the mavlink msg received from
msg, chan = mavlink:receive_chan()
msg is a string and I haven’t found a decode method.
Is this the current state of the art to parse MAVLink messages in Lua scripts right now?
Or, is there a cleaner approach that I haven’t found?
This approach looked promising, but Lua can’t find the “MAVLink/mavlink_msgs” module.
After experimenting more and rummaging around the Lua module, I discovered that I need to generate Lua parses for the messages using pymavlink and then put the MAVLink module in the Lua module on my sdcard in the scripts/modules/MAVLink. Then I was able to use:
local mavlink_msgs = require(“MAVLink/mavlink_msgs”)
functions update()
local msg, chan = mavlink:receive_chan()
if msg then
local parsed_msg = mavlink_msgs.decode(msg, msg_map)
– if (parsed_msg ~= nil) then
local id = parsed_msg.msgid
…