ROS2 Launch file to launch PX4

Currently, there are great examples and documentation of offboard control and multi-vehicle control:

The issue is that there is no clear way to also launch PX4 in the launch scripts. Therefore, to launch 4 vehicles, the user needs to open 4 terminals to run PX4 using make. This becomes more challenging with more vehicles or with additional gazebo configuration.

1 Like

Hi @princealy , thanks for starting this.

Please, take a look at GitHub - osrf/vehicle_gateway: A pluginlib-based C++ library that interfaces with several vehicle SDK's
As far as I know it is the most complete way to have ROS 2 - Gazebo Garden - PX4 all together.
I never used it though

I think there is also this: GitHub - ARK-Electronics/ws_ROS2_PX4_Simulation: Example of controlling PX4 Velocity Setpoints with ROS2 Teleop controls. No need for QGC
created recently.

We might want to consider supporting both ROS2 Foxy (Which means supprot Gazebo Classic) and ROS2 humble (Gazebo Garden).

What do you think?

Hi, I was not aware of the existence of Vehicle Gateway, really don’t know how I missed this from osrf !

This looks promising ! I will give it a try today, report my feelings.

@hamishwillee, I don’t think there is a doc on Vehicle Gateway ? Should we create one ?

So, I tried vehicle_gateway and it seems to me that it is exactly the kind of module that can facilitate entering the field of aerial robotics, as was discussed yesterday during the ROS Aerial working group.

It already has a PX4 package that allows to launch one or multiple instances of the PX4 autopilot, the uOrb ↔ DDS bridge and the Gazebo simulation.

However it uses micro_ros_agent, which is a wrapper of the MicroXRCEAgent. In my case, it fails when I launch px4_sim/launch/

I tested vehicle_gateway with ROS2 Humble, Gazebo Garden and micro_ros_agent v3.0.4, and I suffer crashes of the micro_ros_agent with the following error :

[micro_ros_agent-3] terminate called after throwing an instance of 'std::bad_array_new_length'

The error also happen when I launch only the micro_ros_agent in one terminal and a PX4 instance in another one, so it doesn’t seems to be related to the vehicle_gateway repo.

Is this an issue only on my side, or is it for everyone ?

I tried to remove the micro_ros_agent node from the launch file and launched a MicroXRCEAgent separately, in another terminal. Everything works great in this case.

Anyway, we should make a choice on whether PX4 support vehicle gateway and it is the go-to method to launch PX4 and Gazebo using ROS2, or we add a new launch file directly in the PX4 project (that could be inspired by these ROS launch files).
My opinion is that it would be beneficial for newcomers that want to use ROS to have an easy way to integrate the PX4 Autopilot in their simulations, so I would push to use vehicle_gateway.

1 Like

From what I’ve seen, Vehicle Gateway is in very active development, and from time to time the version from the main branch won’t work properly. Nevertheless, we’ve got our multi-robot setup working based on this version: Pin PX4 to most recent commit (#100) · osrf/vehicle_gateway@16e65ce · GitHub . It’s slightly old now given how fast the commits are coming to this repo, but for me, it works well.

I have had a lot of issues getting Vehicle Gateway to work. Since ROS2 humble is not officially supported yet , I am wondering if there is a way to launch PX4 that works with ROS2 foxy. MY team and I found we can use the to run multiple drones and use the XRCE bridge to connect it to ROS 2. This can be launched like this from a launch file

                HOME + '/PX4-Autopilot/Tools/simulation/gazebo-classic/',
                '-n', str(no_of_drones), '-w', 'baylands'

However, there seems to be a bug where ROS 2 will connect to vehicle 1 through n but not vehicle 0. Not sure if there is another simple way to launch the vehicles without using another framework under such constant development.