Hi guys,
A while ago I created a Mavlink UDP communication library written in kind of modern C++, which we are using in Airvolute company. Since we are trying to create a rich software support for our drones and devices, we try to push some of our projects to be open source. One of them is the library: Airvolute / DroneCore.OS / mavlink-udp-interface · GitLab. You can find the minimal docs on GitLab pages.
We also made example of how to work with it public: Airvolute / DroneCore.OS / mavlink-udp-comm-template · GitLab
So, basically the use case for this is to have mavlink-router instance running and then you can write applications using our mavlink-udp-interface
where each application can do something else (gimbal control, video stream control etc.). I guess it will be generally used for sending control commands from GCS to onboard computer.
The library is meant to be computationally effective. You get messages queued and then you can choose to parse them and look into them if you wish. I also tried to follow Mavlink conventions as much as possible, so each instance of mavlink-udp-interface
sends its own heartbeat with pre-set System and Component ID, so it works seamless with mavlink-router
.
For you to get a basic gist, this is a very basic code snippet took from the template I provided before. It is the part that gets all new mavlink messages:
void MavlinkUdpComm::MavlinkGetNewMessage()
{
while (true) {
mavlink_status_t status;
std::vector<mavlink_message_t> new_messages;
mavlink_udp_.GetAllMessages(new_messages);
if (!new_messages.empty()) {
for (auto & message : new_messages) {
switch (message.msgid) {
case MAVLINK_MSG_ID_HEARTBEAT:
ProcessHeartbeat(message);
break;
case MAVLINK_MSG_ID_COMMAND_LONG:
ProcessCommandLong(message);
break;
default:
break;
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
To conclude, I hope many people come across this discourse post, because this is common bottleneck to develop C++ applications, which results in using Python and pymavlink
which is not always wanted scenario. Also merge requests and feature/fix requests are welcome to improve this as much as possible.
Have a nice day!