This repository contains an example of a ROS 2 node which communicate with a drone using PX4 and ROS 2.
Communication via uXRCE-DDS (PX4 version 1.14.0
).
The repository contains launch file which launch:
- Gazebo simulation (headless / gui options available).
- A PX4 instans which control the simulated drone.
- DDS agent for ROS 2 - PX4 communication.
- An Offboard node which sends setpoints for the control system.
Clone the repository from Github:
https://github.com/citros-garden/drone.git
Then open the repository in VSCode's devcontainer
with reopen in container option
.
The Dockerfile contains all the necessary dependencies for the project, and the
install script will clone PX4-Autopilot and build the firmware, along with building ROS 2 workspace.
This repository contains pre-defined VSCode tasks which are helpful for building and running the example.
They can be run by typing ctrl+p
. In the drop-down menu type task
(space after task) and you should see them appear.
The following tasks are available:
build
- building the ROS 2 workspacelaunch
- launch the simulation inheadless
mode.launch-gui
- launch the simulation inGUI
mode.
Note: The launch
and launch-gui
commands are depend on the build
, so when you launch with task, a build task will run before launch.
Build and source the ROS 2 workspace with:
cd ros2_ws
colcon build
source install/local_setup.bash
Run a headless simulation:
ros2 launch px4_offboard offboard_position_control.launch.py headless:=True
Run a GUI simulation:
ros2 launch px4_offboard offboard_position_control.launch.py headless:=False
Currently, the px4_offboard package contains a node which sends rectangular waypoints to the drone. The 4 waypoints are located in the package's parameters.
-
By default, XRCE-DDS comes with non-ROS 2 default QOS profile. In order to subscribe to the PX4 topics, both in the offboard node and the ROS 2 bag, we changed the XRCE-DDS QOS profile before compiling the PX4 firmware.
-
Some PX4 topics has been removed from the dds_topics.yaml