Prerequisites
- Ubuntu 24.04+
- ROS 2 Jazzy Jalisco
- Gazebo Harmonic
- PX4 Autopilot
- Python 3.10
- Mosquitto (MQTT broker)
System-wide Python Dependency (for ROS 2)
sudo apt install python3-paho-mqtt
ROS Transformer Dependency
sudo apt-get install ros-jazzy-tf-transformations
MAVROS Installation (with extras & messages)
sudo apt-get install -y ros-jazzy-mavros ros-jazzy-mavros-extras ros-jazzy-mavros-msgs
Install GeographicLib Datasets
wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh
chmod +x install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh
QGroundControl (GCS)
Download from:
QGroundControl Download PageInstallation
Clone the Repository
git clone https://github.com/miguel-usp/vff-nav.git
Offboard Velocity Package (run once)
source /opt/ros/jazzy/setup.bash
cd ~/vff-nav/ros_sim
rm -rf build/ install/ log/
colcon build
source install/setup.bash
Web Controller Setup (run once)
cd ~/vff-nav/ros_sim/other_commands
python3 -m venv .venv
source .venv/bin/activate
pip install flask flask-socketio paho-mqtt "numpy>=1.24.0" "numpy-quaternion>=2023.0.0"
Adjust World and Drone Files
Replace the content of the originals, keep the filenames:
- ~/PX4-Autopilot/Tools/simulation/gz/models/x500_lidar_front
- ~/PX4-Autopilot/Tools/simulation/gz/worlds
Use the modified drone and world from:
~/vff-nav/ros_sim/px4_changes
Running
1. Start PX4
cd PX4-Autopilot/
PX4_GZ_WORLD=walls make px4_sitl gz_x500_lidar_front
2. Start MAVROS (using QGroundControl as GCS)
ros2 launch mavros px4.launch fcu_url:=udp://:14540@localhost:14557 gcs_url:=udp://@77.22.9.4:14550
3. ROS 2 ↔ Gazebo Bridge
ros2 run ros_gz_bridge parameter_bridge \
"/world/walls/model/x500_lidar_front_0/link/lidar_sensor_link/sensor/lidar_horizontal/scan@sensor_msgs/msg/LaserScan@gz.msgs.LaserScan" \
"/world/walls/model/x500_lidar_front_0/link/lidar_sensor_link/sensor/lidar_downward/scan@sensor_msgs/msg/LaserScan@gz.msgs.LaserScan" \
"/world/walls/model/x500_lidar_front_0/link/lidar_sensor_link/sensor/lidar_upward/scan@sensor_msgs/msg/LaserScan@gz.msgs.LaserScan"
4. Offboard Velocity Node
source /opt/ros/jazzy/setup.bash
cd ~/vff-nav/ros_sim
source install/setup.bash
ros2 run my_package offboard_velocity
5. Web Controller (run after offboard velocity & motors spinning)
cd ~/vff-nav/ros_sim/other_commands
source .venv/bin/activate
python3 web_controller.py
running on: http://localhost:5000/
Troubleshooting
Common Issues
- Ensure all terminals have ROS 2 sourced
- Verify MQTT broker is running before starting controllers
- Gazebo not launching: Ensure all ROS 2 environment variables are set
- PX4 connection issues: Check MAVLink communication ports
- Permission denied: Add your user to the dialout group:
sudo usermod -a -G dialout $USER
MAVROS Pluginlists
If needed, replace the pluginlists at:
/opt/ros/jazzy/share/mavros/launch/px4_pluginlists.yaml
With the version from:
~/vff-nav/ros_sim/extras
PX4 Crashes
If PX4 crashes, restart:
- PX4 SITL
offboard_velocity- Web Controller
Getting Help
If you encounter issues, please:
- Contact us thanks to our contact on Team
- Create a new issue with detailed error information