A ROS 2 package that integrates PX4 SITL, Gazebo Harmonic, and ros2_control for simulating and controlling a manipulator-equipped drone.
This package provides:
- PX4 + Gazebo SITL integration.
- ros2_control interface for actuators.
- Support for custom URDF/Xacro and SDF models.
The goal is to simulate and control a quadrotor drone with an attached manipulator arm using ROS 2 and Gazebo.
-
Clone PX4 and setup SITL with ROS 2:
git clone https://github.com/PX4/PX4-Autopilot.git --recursive cd PX4-Autopilot make px4_sitl gz_x500 -
Install ROS 2 Humble (desktop version recommended).
-
Source install Gazebo Harmonic:
git clone https://github.com/gazebosim/gz-sim -b harmonic colcon build --merge-install
-
Install gz_ros2_control:
git clone https://github.com/ros-controls/gz_ros2_control.git colcon build --merge-install
-
Export required environment variables:
export GZ_SIM_RESOURCE_PATH=$HOME/iiit_ws/install/darm/share/darm/models:$GZ_SIM_RESOURCE_PATH export GZ_SIM_SYSTEM_PLUGIN_PATH=$HOME/gz_ros2_control_ws/install/gz_ros2_control/lib:$GZ_SIM_SYSTEM_PLUGIN_PATH
-
Build this package:
colcon build --packages-select darm source install/setup.bash
To launch the simulation.
#inside PX4-Autopilot:
prime-run make px4_sitl gz_x500
#launch qgc
#inside arm workspace
prime-run ros2 launch darm trial.launch.py
#inside a serperate terminal
ros2 run darm thrust
#launch xrce dds agent in a seperate terminal
MicroXRCEAgent udp4 -p 8888
#finally publish commands to the arm topics once everything is initialised
ros2 topic pub /{insert controller name here}_effort_controller/commands std_msgs/msg/Float64MultiArray "{data: [0]}"
This will:
- Spawn the
x500_basedrone model with manipulator. - Launch ros2_control with the configured controllers.
Check the Error.md file for common issues and their fixes.
Example:
| Error | Fix | Reason |
|---|---|---|
The supplied world name [world] is reserved |
Rename world in SDF | world is a reserved keyword in Gazebo |
Could not load resource ... Unable to open file |
Ensure meshes are installed under share/darm/urdf/... |
Symlink issues during build |
Failed to load system plugin [gz_ros2_control-system] |
Export GZ_SIM_SYSTEM_PLUGIN_PATH |
Plugin library path not found |
- ROS 2 Tutorials
- ros2_control Documentation
- Gazebo Harmonic Documentation
- PX4 Autopilot Docs
- gz_ros2_control GitHub
- Add unit tests for controller plugins.
- Extend manipulator control with MoveIt.
- Automate mesh/URDF installation without symlinks.
This project is licensed under the Apache 2.0 License.