@TSC21. Thanks for getting back to me. Apologies for not being clear in my first post. I am relatively new to ROS2, PX4 and Gazebo and it is difficult to know what to ask.
What I am trying to do is to use ROS2 to fly a drone in Gazebo. Once I understand the basics, I then want to modify the drone to add several custom parts to the simulation. This may involve changing the behaviour of the drone so I need to understand the how everything fits together.
From what I have read and tried, there seem to be two well trodden paths, 1. ROS2 and Gazebo and 2. PX4, SITL and Gazebo. My guess was that I should be able to use ROS2 to talk to PX4, SITL and Gazebo as was done for ROS using MAVROS. I found px4_ros_com and it seemed to be a replacement for MAVROS but I could not a clear example of how to put it all together. I worked through all the examples in https://dev.px4.io/master/en/middleware/micrortps.html and, after spending a few hours getting it to build using ROS2 only, I was able to run the examples. However, I still could not figure out how to get a drone to fly using ROS2 to command it.
From what I understand of Gazebo, the model of the simulated drone includes a library that tells Gazebo how the model should behave. This library is connected somehow (SITL?) to px4_ros_com so that ROS2 nodes can control the done. So this comes down to me not fully understanding how the px4_ros_com client connects to Gazebo.
Shortly after posting the original question, I started searching again for possible solutions and revisited the OSRF Drone Demo project. After several hours spent picking through the code, I eventually found a test program that did what I wanted: use a ROS2 node to control a drone using the ros2_serial_example package to talk to a SITL PX4 drone in Gazebo. This program commands a drone to take off, fly to a few way points and land. Almost exactly what I want to do to start with.
So my questions are:
- Is there any documentation that shows me how ROS2 uses px4_ros_com with SITL and Gazebo? I want to understand how it all fits together, what bits of software are used to make it all work, which processes use what libraries, ideally referring to code so I can work out which bits I need to modify in the future.
- What are the pros and cons of using px4_ros_com and ros2_serial_example? From my beginners point of view, they both do the same job but it different ways.