A complete simulation and SLAM stack for autonomous drone navigation in GPS-denied environments using PX4, ROS 2, RTAB-Map, and Gazebo Harmonic.
- Overview
- Prerequisites
- 1. Setting Up Workspaces
- 2. PX4 Model Integration
- 3. Terminal Launch Breakdown
- 4. Bridging and Remapping Topics
- 5. RTAB-Map Launch (Terminal 10)
- 6. ENU to NED Conversion for PX4
- 7. Parameter Configuration for PX4
- 8. TF Tree Reference
This repository integrates the following:
- PX4 Autopilot SITL with a depth camera drone.
- ROS 2 Gazebo Harmonic with full RTAB-Map support
- Visual-Inertial Odometry pipeline with ENU to NED conversion for PX4
- Custom odometry bridge to PX4.
- ROS 2 TF publishing and RTAB-Map mapping stack
- Multi-terminal orchestration for GPS-denied SLAM navigation
- Shell script for launching all bridge nodes efficiently
Make sure you clone and build the following repositories:
cd ~/ros2_ws
mkdir -p src && cd src
git clone https://github.com/avianbob/PX4-GPS-Denied-Navigation-RTAB-Mapping.gitcd ~/ros2_ws
colcon build --packages-select GPS_Denied_Navigation odometry_converter
source install/setup.bashThe model gz_x500_depth is used. Copy the model directory provided in this repo to:
rm -rf ~/PX4-Autopilot/Tools/simulation/gz/models/x500_depth
cp -r ~/ros2_ws/src/Model_Files/x500_depth ~/PX4-Autopilot/Tools/simulation/gz/models/This ensures PX4 launches the model correctly with depth camera and odometry plugins.
You can use manual terminals or the provided shell script.
Navigate to the script folder:
cd ~/ros2_ws/src/GPS_Denied_Navigation/scripts
chmod +x all_terminals.sh
./all_terminals.shThis launches 8 terminals automatically.
| Terminal | Purpose |
|---|---|
| 1 | Run PX4 SITL: make px4_sitl gz_x500_depth |
| 2 | Run QGroundControl: ./QGroundControl.AppImage |
| 3 | Run MicroXRCEAgent: MicroXRCEAgent udp4 -p 8888 |
| 4–9 | Run ros_gz_bridge for 6 essential topics (see below) |
| 10 | Run Odometry Converter Node (RTAB Odometry to PX4): python3 odom_to_px4_vision.py |
| 11 | Launch RTAB-Map: see below |
Use ros_gz_bridge to map the following Gazebo topics to ROS 2:
| Gazebo Topic | ROS 2 Topic |
|---|---|
/clock |
/clock |
/world/<world>/model/x500_depth_0/link/camera_link/sensor/IMX214/image |
/rgb/image |
/world/<world>/model/x500_depth_0/link/camera_link/sensor/IMX214/camera_info |
/rgb/camera_info |
/depth_camera |
/depth/image |
/world/<world>/model/x500_depth_0/link/base_link/sensor/imu_sensor/imu |
/imu |
/model/x500_depth_0/odometry |
/odom_px4 |
Replace <world> with your actual Gazebo world name.
ros2 launch GPS_Denied_Navigation depth_camera_simulation.launch.py \
rgb_topic:=/rgb/image \
camera_info_topic:=/rgb/camera_info \
depth_topic:=/depth/image \
odom_topic:=/odom_px4 \
imu_topic:=/imu \
use_sim_time:=true \
subscribe_odom:=true \
wait_imu_to_init:=trueUse the script odom_to_px4_vision.py to convert /odom (ENU) from RTAB-Map into /fmu/in/vehicle_visual_odometry (NED) for PX4.
To run:
cd ~/ros2_ws/src/GPS_Denied_Navigation/scripts
chmod +x odom_to_px4_vision.py
python3 odom_to_px4_vision.pyThis ensures PX4 can use visual-inertial pose estimates for control.
Copy the PX4 parameters file from:
~/ros2_ws/src/GPS_Denied_Navigation/parameters.params
Load it into QGroundControl.
Refer to:
~/ros2_ws/src/GPS_Denied_Navigation/TF Tree.pdf
For understanding TF between base_link, camera, and imu.