Skip to content

Ardupilot applications that use modes and mode-grouping

Notifications You must be signed in to change notification settings

VUISIS/ArduPilot-Modes

Repository files navigation

This repository contains Ardupilot applications written in both Python and C. We used both Arducopter and ArduPlane targets to build and run different modes on SITL board.

Install Ardupilot

Follow Ardupilot instructions to install for the configurations listed below:

  • Board: sitl
  • Vehicle types: copter, plane

Install ArduPilot DroneKit Python

Install DroneKit API.

pip install dronekit-sitl
dronekit-sitl <copter(-version)> [parameters]

Running Ardupilot modes

Run the simvehicle.py tool on one terminal and use another terminal for the next step.

sim_vehicle.py -v ArduCopter --console --map

This will spawn a drone, which is ready to be connected in this TCP address: 127.0.0.1:14550

Now, use another terminal to clone this repository and run different modes:

cd auto_mode
python waypoints.py --connect 127.0.0.1:14550

This will connect to the drone launched by simvehicle.py and run the waypoints mission. Similarly, other modes could be tested.

Drone Simulation

Clone the project including all submodules

Clone the repository recursively to pull all submodules including mavlink, ardupilot and MAVSDK. Note that both ardupilot and MAVSDK are forks under VUISIS organization while mavlink is not the original one but a fork from Ardupilot organization. We maintain separate forks to keep the dependencies stable and also add experimental new features to our forks.

git clone --recursive https://github.com/VUISIS/ArduPilot-Modes.git

If the Ardupilot-Modes project is not cloned with the --recursive flag previously, pull all submodules again.

cd ArduPilots-Modes
git submodule update --init --recursive

Build mavlink C++ library for ardupilot

cd modules/mavlink

python3 -m pip install -r pymavlink/requirements.txt

python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=2.0 --output=generated/include/mavlink/v2.0 message_definitions/v1.0/ardupilotmega.xml

sudo cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=install -DMAVLINK_DIALECT=ardupilotmega -DMAVLINK_VERSION=2.0

sudo cmake --build build --target install

mavlink has one fork under Ardupilot organization. If you decide to use a different fork of mavlink, change the links in .gitmodules while keeping the same submodule path and run the following commands to clear the index.

sudo rm -rf modules/mavlink
git submodule sync
git submodule update --init --recursive --remote

Build and run mavlink C++ application

Skip this step if you are not running any simulation application using mavlink C++ library directly.

cd simulations/sim_adsb
cmake -Bbuild -H. -DCMAKE_PREFIX_PATH=$(pwd)/../../modules/mavlink/install
cmake --build build

Build MAVSDK C++ library

Install dependencies for building MAVSDK

sudo apt update
sudo apt install python3 python3-pip cmake
# If your default python command still points to python 2, install this package to redirect it to python 3. 
sudo apt install python-is-python3

Building MAVSDK

cd modules/MAVSDK/
cmake -Bbuild/default -DCMAKE_BUILD_TYPE=Release -H.
cmake --build build/default -j8

Installing the C++ Library locally with a specific dialect selected for Ardupilot. If some libraries are missing when building, recursively pull submodules inside MAVSDK repository and try again.

cd modules/MAVSDK/
cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=install -DMAVLINK_DIALECT=ardupilotmega -DMAVLINK_VERSION=2.0 
cmake --build build --target install

Build and run MAVSDK C++ applications

Building an application example

cd auto_mode/c/
cmake -Bbuild -H. -DCMAKE_PREFIX_PATH=$(pwd)/../../modules/MAVSDK/install 
cmake --build build -j8

Start SITL (Software in the Loop) for simulation by following the official SITL testing tutorial for installation and the python script sim_vehicle.py can be run from anywhere as a global command.

sim_vehicle.py -v Copter --console --map

If you want to modify the behavior of the default SITL or try some experimental features we have implemented, please switch to our VUISIS fork of ardupilot and run /Tools/autotest/sim_vehicle.py inside ardupilot.

cd modules/ardupilot

# Install required dependencies for Ubuntu and reboot your machine
Tools/environment_install/install-prereqs-ubuntu.sh -y
# Reload the path (log-out and log-in to make permanent)
. ~/.profile

# Pull and update all submodules in case you didn't clone the main project recursively
git submodule init
git submodule update --recursive
./Tools/gittools/submodule-sync.sh

# Build and compile
./waf configure --board sitl
./waf clean
./waf copter

# Run SITL simulation
python sim_vehicle.py -v Copter --console --map

Running an application example

./build/waypoints tcp://:5762

Optionally, A bash script is provided to automate the building and running of application examples. Make sure that the MAVSDK C++ library is installed and SITL is running in the background following the previous steps, then execute the run.sh script inside root directory.

# Please specify mode: AUTO, GUIDED, AVOID
. ./run.sh AUTO

About

Ardupilot applications that use modes and mode-grouping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published