ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Low level encapsulation of Mavros messages using MAVLink


#1

Hi all,

I’d like to have a go at implementing a UART based Mavros client / server implementation, The client will be running on a homegrown ARM Cortex F4 flight controller and the server side I plan to implement on a more powerful “Companion Computer”, probably a Raspberry PI.

I’m struggling to find any detailed information about how other systems perform the encapsulation with MAVLink as I would like to develop code that I could easily re-use with other systems.

I now have a basic understanding of ROS but I still have a few moderately fundamental questions with regard to Mavros that I’m trying to find answers for. I have started to have a look though some of the implementing code bases such as PX4. However, there is a lot of code and this is taking a while!

Below are a few “overlapping” and pretty basic low level questions about the MAVLink encapsulation that I’m hoping someone can answer, or perhaps point me at some appropriate code or a technical description (I have unsuccessfully looked for this).

  • Which MAVLink message ID or IDs are used?
  • Are these custom MAVLink messages? i.e. in the range 180 - 229 and thus application specific.
  • Do distinct Mavros message get encapsulated as specific custom MAVLink message?

Many thanks!


#2

Hello,

I didn’t fully understand what you tried to do. But here is some clue:
MAVROS is just a bridge between ROS messaging and Mavlink.

About Mavlink usage. The only need message is really the heartbeat as it contains essential status information and implement the mavlink routing feature. Mavlink C implementation already got big helpers function to help you implement the sender and receiver functions.

Mavlink common.xml implements a set of common usefull message. If those don’t suit you, you can easily create your own set of message … but you will need to compile MAVROS yourself to include your messages. MAVROS only undestand message from https://github.com/mavlink/mavlink/tree/master/message_definitions/v1.0

You will find more help here :
https://mavlink.io/en/


#3

Thanks for your reply.

I understand how MAVLink works and have a good API level understanding of ROS.

Essentially I’m trying to determine how a serial Mavros bridge works, but at the lowest level. i.e. How to implement a client capable of talking to an other Mavros compatible systems via a serial port using MAVLink as the transport layer. I suspect that it’s straightforward, but it’s difficult to determine precisely without any documentation or by looking though existing code bases like PX4.

I have now brought a Pixhawk that I intend to setup and use with the existing Mavros tools. Once working, I’ll monitor the serial comms and this will hopefully fill in the gaps in my current understanding of how it works.

ROS appears to be very well documented at all levels, but as far as I can tell this isn’t the case for Mavros. Once I’ve figured it out I will post a description just in case anyone else ever needs build their own implementation.

Meanwhile, any low level insights would be gratefully received!


#4

Mavros only write mavlink message on serial nothing more.
What you want is basic mavlink routing. You want to send a message from a mavlink device to another
Mavros will connect to only one mavlink ID.
So you need :
Mavros ( id=1,cmpnt=255)< - - uart - - > device (1,1) <–uart–> device2 (2,1) <-- uart–> mavros (2,255)
Normally, mavros filter messages by id via ros plugin api. You can easily add more plugin to handle more message or catch messages from /mavlink_from