Skip to content

Lightweight Gazebo/ROS-based Simulator for Unmanned Aerial Vehicles (C++/ROS/PX4)

License

Notifications You must be signed in to change notification settings

lalala518418/uav_simulator

 
 

Repository files navigation

Lightweight Gazebo/ROS-based Simulator for Unmanned Aerial Vehicles (UAVs)

This package implements a lightweight quadcopter unmanned aerial vehicles (UAVs) simulator including various static and dynamic based on Gazebo/ROS. It also includes an optional PX4-based quadcopter simulation wrapper.

Author: Zhefan Xu, Computational Engineering & Robotics Lab (CERLAB) at Carnegie Mellon University (CMU).

If you find this work helpful, kindly show your support by giving us a free ⭐️. Your recognition is truly valued.

This repo can be used as a standalone package and also comes as a module of our autonomy framework.

I. Installation Guide

This repo has been tested on ROS Melodic with Ubuntu 18.04 and ROS Noetic with Ubuntu 20.04.

a. Non-PX4 Simulator (Required)

To install the non-PX4 simulator, please follow the standard catkin package make process as follows:

sudo apt-get install ros-[melodic/noetic]-mavros* # this package depends on mavros related ROS packages
git clone https://github.com/Zhefan-Xu/uav_simulator.git

cd ~/catkin_ws
catkin_make

setup environment variable. Add following to your ~/.bashrc

source path/to/uav_simulator/gazeboSetup.bash

b. PX4-based Simulator Wrapper (Optional but Recommended)

Please make sure that you have follow the previous steps to build the non-px4 simulator.

Step 1: Install vehicle models and make it compatible with your current ROS. The following lines give the summaries:

🍎 Current PX4 version has some problems with offboard mode, please use v1.12.0 as modified in the following lines:🍎

cd directory/to/install # this should not be your catkin workspace

git clone https://github.com/PX4/PX4-Autopilot.git --recursive --branch v1.12.0
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh # this step will ask you to reboot

# Please make sure you reboot after the previous step
cd /path/to/PX4-Autopilot
DONT_RUN=1 make px4_sitl_default gazebo

Step 2: Add the following script to ~/.bashrc. Remember to replace <PX4-Autopilot_clone> with the path to your PX4-Autopolot directory. This step will you setup the environment variables properly.

source <PX4-Autopilot_clone>/Tools/setup_gazebo.bash <PX4-Autopilot_clone> <PX4-Autopilot_clone>/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:<PX4-Autopilot_clone>
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:<PX4-Autopilot_clone>/Tools/sitl_gazebo

Step 3: Install geographiclib datasets for PX4 simulation.

wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo bash ./install_geographiclib_datasets.sh  

II. Quick Start

a. To launch the non-PX4 simulator with a quadcopter:

roslaunch uav_simulator start.launch

You should be able to see a customized quadcopter in a predefined gazebo environment as shown below:

simulator

b. To launch the PX4 simulator with a quadcopter:

roslaunch uav_simulator px4_start.launch

You should be able to see a PX4 IRIS quadcopter in a predefined gazebo environment as shown below:

px4_simulator

III. Keyboard Control

Our non-PX4 customized simulator supports the keyboard control function. You are able to control the quadcopter motion when you click the keyboard controller panel shown as below:

keboard_control

IV. Simulation Environments

  • There are various predefined environments in this package and you can easily switch environment when you modify the launch file located in uav_simululator/launch/start.launch or uav_simululator/launch/px4_start.launch. All the predifined environments are listed in the lanuch files.
  • There are some environments which contains dynamic objects (e.g. moving persons). You can distinguish those dynamic environments by the environments' names. For example, the environment name floorplan1_dynamic_16.world indicates that there are 16 dynamic objects in the floorplan1 environment.

One example of the dynamic environment is shown as below:

Screenshot from 2023-12-18 20-36-34

V. ROS Topics

Here lists some important ROS topics related to the simulator:

  • Non-PX4 Simulator:
    • /CERLAB/quadcopter/cmd_acc: The command acceleration to the quadcopter.
    • /CERLAB/quadcopter/pose: The ground truth pose of the quadcopter.
    • /CERLAB/quadcopter/odom: The ground truth odom of the quadcopter.
    • /CERLAB/quadcopter/setpoint_pose: The command pose to the quadcopter.
    • /camera/color/image_raw: The color image from the onboard camera.
    • /camera/depth/image_raw: The depth image from the onboard camera.
    • /camera/depth/points: The depth cloud from the onboard camera.
  • PX4 Simulator
    • /mavros/setpoint_raw/attitude: The command to the quadcopter.
    • /mavros/local_position/pose: The ground truth pose of the quadcopter.
    • /mavros/local_position/odom: The ground truth odom of the quadcopter.
    • /mavros/setpoint_position/local: The command pose to the quadcopter.
    • /camera/color/image_raw: The color image from the onboard camera.
    • /camera/depth/image_raw: The depth image from the onboard camera.
    • /camera/depth/points: The depth cloud from the onboard camera.

About

Lightweight Gazebo/ROS-based Simulator for Unmanned Aerial Vehicles (C++/ROS/PX4)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.0%
  • CMake 13.6%
  • Shell 0.4%