Which should i use mavros or px4_ros_com

i don’t really get the difference between mavros and px4_ros_com, can someone pls explain it simply the difference between them?
which one should I use with ROS2?

Basically, PX4 uses a protocal called “Mavlink” to exchange messages. It’s the same protocol that is decoded when you use QGroundControl, or connect to it with the mavlinkshell Python script, for example.

To connect it with ROS, there are two ways in theory:

  • Mavros, the old way. Mavros is a ROS 1 package that connects to the board running PX4 using the Mavlink protocol, and republishes these messages as ROS topics on a ROS 1 network

  • RTPS, the new way. This is the new way that is supposed to work better and made for ROS2. You compile PX4 with the rtps_agent and run it, and then on the ROS computer side, you run another ROS node called rtps_client that connects to a PX4 board running rtps_agent and republishes the info as ros nodes.

Now, in practice, here is my EXTREMELY biased view:

Use Mavros.

I really wanted to use ROS 2, and on the PX4 website, they say it’s the preferred way of doing it. So I gave it a try, and had a horrible experience with everything. Here are my reasons:

  • Compiling everything for fastRTPS seems a bit hacky at this stage, so it took me a super long time to make everything kinda work.
  • There are almost no examples of using it. I tried for days and days to make it work over wifi, and I did not make it work. The documentation says “it’s possible to use it with wifi” and that’s all. Maybe it really is, but I found no info whatsoever. Maybe it’s so easy that a simple answer from someone who did it was everything I needed, with leads to the next problem…
  • No one’s using it. I posted everything. Here, on Reddit. Almost no one replied. And the ones who did also didn’t know how to use it, so they were mostly telling me they were also interested in knowing if it was possible.
  • Every other tutorial you’re gonna find will be about how to do everything using Mavros instead of fastRTPS. Even on the PX4 website, if you plan on using, for example, with a mocap system like Vicon, etc, their documentation will be Mavros focused.

So yeah, since you seem like a beginner (like me), stick to Mavros and ROS1 for now. It will probably make your life easier.

2 Likes

alright, thanks for the answer.
before, I really want to use ROS2 directly to PX4. But, as you said it’s so hard to search for examples of using fastRTPS and so on. So I think I should use mavros instead.
for using mavros is it only can be done in ROS 1?
did you have any recomendation videos or github repo for mavros example?

No idea if it’s possible to use Mavros with ROS2 at the moment. Maybe, but you’ll be going to use something that will be on early stages of development and again, any problem you find you’ll have to deal with it alone.
For Mavros with ROS1, I think the documentation on how to install it on the px4 website is probably the best you’re gonna get

yeah, from the changelog it’s possible but at the moment it is still Alpha release

thanks again for the answer