Gazebo is a 3D simulation environment for autonomous robots. It can be used with ROS as complete robotics simulation suite or standalone, and this guide covers the simpler to set up standalone operation.
The installation requires to install Gazebo and our simulation plugin.
Mac OS requires Gazebo 6.
brew install gazebo6
The PX4 SITL uses the Gazebo simulator, but does not depend on ROS. The simulation can be interfaced to ROS the same way as normal flight code is.
If you plan to use PX4 with ROS, make sure to follow the Gazebo version guide for version 6 for ROS.
Follow the Linux installation instructions for Gazebo 6.
From within the source directory of the PX4 Firmware run the PX4 SITL with one of the airframes (Quads, planes and VTOL are supported, including optical flow):
cd ~/src/Firmware make posix_sitl_default gazebo
cd ~/src/Firmware make posix gazebo_iris_opt_flow
cd ~/src/Firmware make posix_sitl_default gazebo_standard_vtol
cd ~/src/Firmware make posix_sitl_default gazebo_tailsitter
This will bring up the PX4 shell:
[init] shell id: 140735313310464 [init] task name: mainapp ______ __ __ ___ | ___ \ \ \ / / / | | |_/ / \ V / / /| | | __/ / \ / /_| | | | / /^\ \ \___ | \_| \/ \/ |_/ Ready to fly. pxh>
The system will print the home position once it finished intializing (
telem> home: 55.7533950, 37.6254270, -0.00). You can bring it into the air by typing:
pxh> commander takeoff
To extend or customize the simulation interface, edit the files in the
Tools/sitl_gazebo folder. The code can be accessed through the sitl_gazebo repository on Github.
The simulation can be interfaced to ROS the same way as onboard a real vehicle.