Handling of ROS / MAVROS messages on bare metal hardware

557 Views Asked by At

I have a project which involves simple serial communication with a proxy using a predefined small subset of MAVLink and ROS / MAVROS messages.

I'm running on my own bare metal embedded ARM Cortex F4 hardware with no underlying operating system (other than my own framework that supports serial comms and other hardware I/O etc).

With respect to the MAVLink aspect of this task, the process seems relatively straightforward. Message IDs are predefined and the MAVLink header files (generated from the XML) contain the packing and serialisation functions. I have successfully implemented and tested this aspect.

However, I'm struggling to achieve the same functionality with ROS and MAVROS.

I notice that the MAVROS distribution contains header files that define the MAVROS messages and conversion to / from MAVLink messages.

The following bullet points outline the process I'm trying to understand.

  • A message is received as a MAVLink packet, how do I determine if it's actually a ROS / MAVROS message? I assume that the MAVLink message ID will be different to standard MAVLink messages, but I cannot find any information about this.
  • Once I know it's a ROS / MAVROS message, I can convert it using the MAVLink to MAVROS conversion code defined in the MAVROS distribution (as mentioned above).
  • Now that I have a MAVROS message, how can I determine the actual message type and parse and extract its payload? I assume that this relates to the first bullet point (identifying the ROS / MAVROS messages).
  • Similarly, how do I reverse this process to build a MAVROS message from the required payload for a particular ROS message type? Its subsequent conversion to MAVLink and serialisation is straightforward as described above.

Ultimately all I want to do is serialise and de-serialise a small subset of the ROS / MAVROS messages without the requirement of a large framework overhead. Whilst the information allowing me to do this with MAVLink is readily available and easy to implement, I cannot find the equivalent information I need to implement the same functionality with ROS / MAVROS messages.

Any help or clarification would be very welcome!

Many thanks!

1

There are 1 best solutions below

0
On

I had worked with pixhawk sometime back. I will try my best to help here. Documentations on mavros, as I am aware of includes:

Basically, mavros consists of two parts:

  • libmavcon
  • mavros

libmovcon is the mavlink transiver that sends/receives messages from radio/ethernet/wifi network and publish/subscribe the ENCODED (still in MAVLINK's format) message to ROS message distribution system. mavros is the glue piece that publish/subscribe to the ENCODED version of the message and selectively decode and translate them into ROS messages. (eg. mavlink global velocity to ROS geometry_msgs/TwistStamped)

Back to your question:

  1. In libmavcon, you define the hardware resource (serial port, udp port etc.) that will send/receive mavlink messages.
  2. Yes, mavros will do the conversion between mavlink message definition and ROS message definition.
  3. mavros will compile a table to mavlink message ID and its binding ROS message. There is done by plugins. You can create your own plug-in to cover custom messages.
  4. save as 3