Skip to content

cweekiat/drone_sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Drone Simulation using Ardupilot

More detailed step-by-step installation (should you require) can be found here. https://github.com/Intelligent-Quads/iq_tutorials/tree/master

FULL Installation Guide

1. Install ROS

  • Do Desktop-full Install
  • Follow until Step 1.7 at the end of the page

First, install ROS Noetic using the following instructions: http://wiki.ros.org/noetic/Installation/Ubuntu

2. Set Up Catkin workspace

We use catkin build instead of catkin_make. Please install the following:

sudo apt-get install python3-wstool python3-rosinstall-generator python3-catkin-lint python3-pip python3-catkin-tools
pip3 install osrf-pycommon

Then, initialize the catkin workspace:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init

3. Dependencies installation

Install mavros and mavlink from source:

cd ~/catkin_ws
wstool init ~/catkin_ws/src

rosinstall_generator --upstream mavros | tee /tmp/mavros.rosinstall
rosinstall_generator mavlink | tee -a /tmp/mavros.rosinstall
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src
rosdep install --from-paths src --ignore-src --rosdistro `echo $ROS_DISTRO` -y

catkin build

Add a line to end of ~/.bashrc by running the following command:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

update global variables

source ~/.bashrc

install geographiclib dependancy

sudo ~/catkin_ws/src/mavros/mavros/scripts/install_geographiclib_datasets.sh

4. Installing Ardupilot and MAVProxy Ubuntu 20.04

Clone ArduPilot

In home directory:

cd ~
sudo apt install git
git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot

Install dependencies:

cd ardupilot
Tools/environment_install/install-prereqs-ubuntu.sh -y

reload profile

. ~/.profile

If the next step "git submodule update" fails

git config --global url.https://.insteadOf git://

Checkout Latest Copter Build

git checkout Copter-4.0.4
git submodule update --init --recursive

Run SITL (Software In The Loop) once to set params:

cd ~/ardupilot/ArduCopter
sim_vehicle.py -w

5. Install Gazebo [20.04]

Setup your computer to accept software from http://packages.osrfoundation.org:

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

Setup keys:

wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

Reload software list:

sudo apt update

Install Gazebo:

Ubuntu [20.04]

sudo apt-get install gazebo11 libgazebo11-dev

for more detailed instructions for installing gazebo checkout http://gazebosim.org/tutorials?tut=install_ubuntu

Install Gazebo plugin for APM (ArduPilot Master) :

cd ~
git clone https://github.com/khancyr/ardupilot_gazebo.git
cd ardupilot_gazebo

build and install plugin

mkdir build
cd build
cmake ..
make -j4
sudo make install
echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc

Set paths for models:

echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> ~/.bashrc
. ~/.bashrc

Test Simulator

In one Terminal (Terminal 1), run Gazebo:

gazebo --verbose ~/ardupilot_gazebo/worlds/iris_arducopter_runway.world

In another Terminal (Terminal 2), run SITL:

cd ~/ardupilot/ArduCopter/
sim_vehicle.py -v ArduCopter -f gazebo-iris --console

6. Finally, installing the simulation

Install Drone Kit

sudo pip install dronekit simple-pid

Clone repository into catkin workspace.

cd catkin_ws/src/
git clone https://github.com/cweekiat/drone_sim.git
cd ~/catkin_ws/
catkin build
echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/drone_sim/models" >> ~/.bashrc
echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/drone_sim/worlds" >> ~/.bashrc
echo "GAZEBO_RESOURCE_PATH=~/ardupilot_gazebo/worlds:${GAZEBO_RESOURCE_PATH}" >> ~/.bashrc
echo "GAZEBO_PLUGIN_PATH=~/ardupilot_gazebo/build:${GAZEBO_PLUGIN_PATH}" >> ~/.bashrc

Running the simulation

Launch gazebo world

roslaunch drone_sim multi_drone.launch

Close all terminals you do not need and run simulation.

cd ~/catkin_ws/src/drone_sim/scripts
chmod +x start_sim end_sim multi-ardupilot.sh target.sh observer.sh
./start_sim

Note: start_sim will run every launch file and python script require for the simulation. It will open many terminals & windows in the process.

About

Multi-Drone simulation using Ardupilot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages