Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

A SITL guide for setting up Ardupilot, Gazebo & ROS

Notifications You must be signed in to change notification settings

yanhwee/ardupilot-gazebo-ros-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArduPilot-Gazebo-ROS SITL Guide

A guide for setting up ArduPilot, Gazebo and ROS.

An example project: https://github.com/yanhwee/helium

Software Covered

  • ArduPilot
  • ArduPilot Gazebo Plugin (khancyr)
  • Gazebo 9
  • ROS Melodic
  • MAVROS (ROS package)

Requirements

Tested on Native Ubuntu 18.04.4.

Quick Installation

Script defaults to the home directory as the initial working directory, modifiable in the script. Script will use this working directory to git clone ArduPilot & ArduPilot Gazebo Plugin repositories.

wget -O - https://raw.githubusercontent.com/yanhwee/ardupilot-gazebo-ros-guide/master/install.bash | bash

Script will refresh the sudo timeout every 10 mins so intallation will not be interrupted. Please do not sudo bash. This will run as root and script will not work.

Please restart after the installation is done.

The guide below walks through the steps found in the script.

References

  1. ROS Melodic Ubuntu Installation
    http://wiki.ros.org/melodic/Installation/Ubuntu

  2. ArduPilot
    https://ardupilot.org/dev/docs/building-setup-linux.html

  3. khancyr ArduPilot Gazebo Plugin
    https://github.com/khancyr/ardupilot_gazebo

  4. ROS package: MAVROS
    https://github.com/mavlink/mavros/tree/master/mavros

Installation Guide

0. Prerequisites

  1. Git
    • sudo apt install git

1. ROS (and Gazebo)

  1. Follow all steps:
    http://wiki.ros.org/melodic/Installation/Ubuntu
    • Install: ros-<distro>-desktop-full
    • For our case: ros-melodic-desktop-full
    • Gazebo will be installed alongside ROS

2. ArduPilot

  1. Git clone:
    https://ardupilot.org/dev/docs/building-setup-linux.html#cloning-with-the-command-line

  2. Install required packages:
    https://ardupilot.org/dev/docs/building-setup-linux.html#install-some-required-packages

3. ArduPilot Gazebo Plugin (khancyr)

  1. Git clone:
    https://github.com/khancyr/ardupilot_gazebo#usage-

    • Skip directly to
      git clone https://github.com/khancyr/ardupilot_gazebo
  2. Build:
    https://github.com/khancyr/ardupilot_gazebo#usage-

    • Continue after the git clone
    • Set the paths as well

4. MAVROS

  1. Binary Installation
    https://github.com/mavlink/mavros/tree/master/mavros#binary-installation-deb

    • Replace 'kinetic' with 'melodic'
    • sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras
  2. Install GeographicLib
    https://github.com/mavlink/mavros/tree/master/mavros#binary-installation-deb

5. Recommended

  1. catkin_tools
    https://ardupilot.org/dev/docs/ros-install.html#installing-mavros
    • sudo apt-get install python-catkin-tools

6. Optional

  1. RQT (ROS package)
    https://ardupilot.org/dev/docs/ros-install.html#installing-mavros
    • Replace 'kinetic' with 'melodic'
    • sudo apt-get install ros-melodic-rqt ros-melodic-rqt-common-plugins ros-melodic-rqt-robot-plugins

Quick Test

  1. Without ROS

    1. https://ardupilot.org/dev/docs/using-gazebo-simulator-with-sitl.html#start-the-simulator
    2. https://ardupilot.org/dev/docs/copter-sitl-mavproxy-tutorial.html
  2. With ROS

    • Check out Intelligent Quad Videos
    • Or look at Learning Resources (Connecting to ROS) & continue with Quick Test (Without ROS step 2)

Software Architecture Overview

These psuedo-diagrams are for you to get an idea of how the whole thing works.

Typical Drone System (Physical Components)

Physical Diagram

Software-in-the-Loop (SITL Components)

SITL Diagram

Learning Resources

  1. Intelligent Quad

    1. YouTube
      https://www.youtube.com/playlist?list=PLy9nLDKxDN683GqAiJ4IVLquYBod_2oA6
    2. GitHub
      https://github.com/Intelligent-Quads/iq_tutorials
  2. ROS

    1. Tutorials
      http://wiki.ros.org/ROS/Tutorials
    2. Understanding package.xml
      http://wiki.ros.org/roslaunch/XML
    3. IDEs
      http://wiki.ros.org/IDEs
  3. Catkin

    1. Workspaces
      http://wiki.ros.org/catkin/workspaces
    2. catkin_tools
      https://catkin-tools.readthedocs.io/en/latest/quick_start.html
  4. CMake

    1. Understanding CMakeLists.txt
      https://www.youtube.com/playlist?list=PLK6MXr8gasrGmIiSuVQXpfFuE1uPT615s
    2. Documentation
      https://cmake.org/cmake/help/v3.17/manual/cmake.1.html
  5. ArduPilot

    1. Connecting to ROS
      https://ardupilot.org/dev/docs/ros-sitl.html
    2. SITL Architecture
      https://ardupilot.org/dev/docs/sitl-simulator-software-in-the-loop.html#sitl-architecture
    3. Using SITL (sim_vehicle.py & MAVProxy)
      https://ardupilot.org/dev/docs/using-sitl-for-ardupilot-testing.html
    4. SITL Examples
      https://ardupilot.org/dev/docs/sitl-examples.html
  6. ArduCopter

    1. Paramters List
      https://ardupilot.org/copter/docs/parameters.html
    2. Flight Modes
      https://ardupilot.org/copter/docs/flight-modes.html
  7. MAVLink

    1. MAVLink Messages
      https://mavlink.io/en/messages/common.html
    2. Copter Commands (Guided)
      https://ardupilot.org/dev/docs/copter-commands-in-guided-mode.html#copter-commands-in-guided-mode
    3. Copter Commands (Auto / Mission)
      https://ardupilot.org/copter/docs/common-mavlink-mission-command-messages-mav_cmd.html
    4. Pymavlink (Also applicable to ArduCopter)
      https://www.ardusub.com/developers/pymavlink.html
  8. Gazebo

    1. Tutorials
      http://gazebosim.org/tutorials
    2. Digitial Elevation Map (DEM)
      1. Tool for getting real-life DEM
        https://terrain.party/
      2. Heightmap Tutorial
        https://vimeo.com/58409707
    3. SDFormat Specification
      http://sdformat.org/spec

Troubleshooting

1. ArduPilot

  1. sim_vehicle.py not found
    • Restart Ubuntu

2. Gazebo

  1. Slow Gazebo startup or
    libcurl: (6) Could not resolve host: api.ignitionfuel.org

  2. Bad lighting

3. Visual Studio Code

  1. Linting for cpp files
    1. Find ROS cpp path
      1. Can be found by
        cd / && sudo find -name 'ros.h'
    2. Add path to "c_cpp_properties.json' include path

4. Mavproxy

  1. Any Problems

    • Try pip install -U mavproxy
  2. Re-requesting WPs

Tips

1. QGroundControl

  1. Rebooting ArduPilot
    1. Click on the Gear Icon (Vehicle Setup), top-left of the screen.
    2. Click on the Parameter Tab, bottom left of the Vehicle Setup screen.
    3. Click Tools, top-right of the screen.
      • If not found, click on the Clear Button beside the Search Bar first.
    4. Click "Reboot Vehicle"

Releases

No releases published

Packages

No packages published

Languages