It is suggested to choose one gazebo version between Gazebo Garden and Gazebo 11
Main references are
- Using SITL with Gazebo for Gazebo Garden.
- Using SITL with legacy versions of Gazebo for Gazebo 11.
Install Gazebo Garden following the steps at Docs/Gazebo Garden-->Binary Installation on Ubuntu, which are
sudo apt-get update
sudo apt-get install lsb-release wget gnupg
and then
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update
sudo apt-get install gz-garden
To test if the installation is done, we can run
gz sim -v4 -r shapes.sdf
and it is OK if we can see
Video tutorials provided by Intelligent Quads can be found on Youtube Drone Dev Environment Ubuntu 20 04 Update
Given that our development environments are
- Ubunt 20.04
- ROS noetic
- Gazebo 11.12.0
- install gazebo 11
sudo apt-get install gazebo11 libgazebo11-dev
- get source code of Ardupilot plugins for gazebo 11.X
cd where_you_want
git clone https://github.com/khancyr/ardupilot_gazebo
- build ardupilot plugins for gazebo 11.X
mkdir build
cd build
cmake ..
make -j4
sudo make install
echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
- add the path of models and worlds provided by ardupilot plugins into .bashrc after you change where_your_ardupilot_gazebo_is below
echo 'export GAZEBO_MODEL_PATH=where_your_ardupilot_gazebo_is/ardupilot_gazebo/models' >> ~/.bashrc
- add gazebo mode path
echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/iq_sim/models" >> ~/.bashrc
- launch a gazebo environment with iris model with iq_sim pkg
- get source code of iq_sim
git clone https://github.com/Intelligent-Quads/iq_sim.git
- add mode path of iq_sim to gazebo
echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/iq_sim/models" >> ~/.bashrc
- build and resource iq_sim pkg
- roslaunch gazebo env of iris_arducopter_runway
roslaunch iq_sim runway.launch
Check Youtube Drone Dev Environment Ubuntu 20 04 Update to install Ardupilot.
Read Setting up the Build Environment (Linux/Ubuntu).
Run ardupilot firmware
cd Ardupilot/ArduCopter
sim_vehicle.py -v ArduCopter -f gazebo-iris --console
# OR
sim_vehicle.py -v ArduCopter --console --map
we should find an interface, a council and a terminal.
The ROS package mavros provides support for Ardupilot. Then we can run mavros to get drone information into ROS.
In simulation, we specify '''fcu_url:=udp://127.0.0.1:14551@14555'''.
roslaunch mavros apm.launch fcu_url:=udp://127.0.0.1:14551@14555
With the help of mavros, we can get mavros topics in ROS showing drone information
Since we command the drone to switch to guided mode and take off to a height of 5m with
mode guided
arm throttle
takeoff 5
then we check drone state and position in ROS
rostopic echo /mavros/state
rostopic echo /mavros/local_position/pose
with the state being guided and position being 5m
-
run
gz sim -v4 -r iris_runway.sdf
-
run Ardupilot firmware
cd Ardupilot/ArduCopter sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --map --console
-
run mavros to enable communication between Ardupilot and ROS
roslaunch mavros apm.launch fcu_url:=udp://127.0.0.1:14551@14555
-
make drone switch to guided mode and take off In the same terminal of running sim_vehicle.py, we use the following commands to make the drone take off
mode guided arm throttle takeoff 5
We should see the drone take off and hover in Gazebo
if we echo rostopics /mavros/state and /mavros/local_position/pose, then we should find
- the drone's mode is guided
- its height is 5m.