edit

ArduPilot installation and running

Overview

You can run ArduPilot on Raspberry Pi 3 or 2 with Navio. The autopilot's code works directly on Raspberry Pi. For ArduPilot to work properly please use the configured Raspbian distribution that we provide.

Current vehicle versions

Emlid Raspbian has preinstalled ArduPilot. It includes all vehicles and is based on the most stable branch available. Currently these are:

  • ArduPlane: 3.7.1
  • ArduRover: 3.1.2
  • ArduCopter: 3.4.6

Greeting

Once you ssh into Raspberry Pi you'll be greated with a message that looks like this:

To enable ArduPilot on boot:
STEP 1:
Choose your vehicle, board and ArduPilot version using update-alternatives
(Please, read carefully all options and select appropriate one for either Navio 2 or Navio+)
        - sudo update-alternatives --config arducopter
        - sudo update-alternatives --config arduplane
        - sudo update-alternatives --config ardurover

STEP 2:
Set your GCS IP
        - sudo nano /etc/default/arducopter
        - sudo nano /etc/default/arduplane
        - sudo nano /etc/default/ardurover
STEP 3:
Reload configuration by issuing these commands
        - sudo systemctl daemon-reload

To start ardupilot (this won't load ArduPilot on boot):
        - sudo systemctl start arducopter
        - sudo systemctl start arduplane
        - sudo systemctl start ardurover


STEP 4:
Enable service on boot:
        - sudo systemctl enable arducopter
        - sudo systemctl enable arduplane
        - sudo systemctl enable ardurover

To disable ArduPilot on boot:
        - sudo systemctl disable arducopter
        - sudo systemctl disable arduplane
        - sudo systemctl disable ardurover

We'll guide you through what's going on under the hood in the sections below.

Systemd

For launching ArduPilot we are using systemd init system which provides manager for all services and processes. The main command used to control systemd is systemctl. Some of its uses are:

  • examining the system state
  • managing the system and services.

See man systemctl for more details.

Choosing a vehicle, version and board

All of the ArduPilot binaries are installed to /opt/ardupilot/ardu[vehicle]-[ap_major_version]/bin We use update-alternatives utility for the binary selection. This utility maintains symlinks to /usr/bin/arducopter, /usr/bin/arduplane and /usr/bin/ardurover.

In the example below we'll use arducopter but it could've been just as well arduplane or ardurover.

pi@navio: ~ sudo update-alternatives --config arducopter

This will produce the output like this:

There are 18 choices for the alternative arducopter
(providing /usr/bin/arducopter).

Selection Path                                               Priority  Status
-----------------------------------------------------------------------------
  0    /opt/ardupilot/navio2/arducopter-3.4/bin/arducopter-y6     50   auto
  1    /opt/ardupilot/navio/arducopter-3.4/bin/arducopter-coax    50   manual
  2    /opt/ardupilot/navio/arducopter-3.4/bin/arducopter-heli    50   manual
  ...
  15   /opt/ardupilot/navio2/arducopter-3.4/bin/arducopter-quad   50   manual
  16   /opt/ardupilot/navio2/arducopter-3.4/bin/arducopter-single 50   manual
  17   /opt/ardupilot/navio2/arducopter-3.4/bin/arducopter-tri    50   manual
* 18   /opt/ardupilot/navio2/arducopter-3.4/bin/arducopter-y6     50   manual

Press enter to keep the current choice[*], or type selection number:

The first line shows the vehicle that is launched by default. If you want to select another frame, board or version you need to select an appropriate one.

For example, in case you build a quad on Navio 2 and want to use ArduCopter-3.4 you will need to type 15 and then press enter.

Specifying launching options

Open the file:

pi@navio: ~ $ sudo nano /etc/default/arducopter 

Here you can specify IP of your ground station.

TELEM1="-A udp:127.0.0.1:14550"
#TELEM2="-C /dev/ttyAMA0"

# Options to pass to ArduPilot
ARDUPILOT_OPTS="$TELEM1 $TELEM2"

# -A is a console switch (usually this is a Wi-Fi link)

# -C is a telemetry switch
# Usually this is either /dev/ttyAMA0 - UART connector on your Navio
# or /dev/ttyUSB0 if you're using a serial to USB convertor

# -B or -E is used to specify non default GPS

All lines marked '#' are comments and have no effect.

For example, you'll need to modify TELEM1 to point to your IP like this:

TELEM1="-A udp:192.168.1.2:14550"

Where 192.168.1.2 is the IP address of the device with the Ground Control Station - your laptop, smartphone etc.

Tip

You can add additional options to ARDUPILOT_OPTS that are then passed to ArduPilot by adding new TELEM environment variables like this: TELEM3="-E /dev/ttyUSB1" ARDUPILOT_OPTS="$TELEM1 $TELEM2 $TELEM3"

Mapping between switches and serial ports (TCP or UDP can be used instead of serial ports):

  • -A - serial 0 (always console; default baud rate 115200)
  • -C - serial 1 (normally telemetry 1; default baud rate 57600)
    3DR Radios are configured for 57600 by default, so the simplest way to connect over them is to run with -C option.
  • -D - serial 2 (normally telemetry 2; default baud rate 57600)
  • -B - serial 3 (normally 1st GPS; default baud rate 38400)
  • -E - serial 4 (normally 2st GPS; default baud rate 38400)
  • -F - serial 5

Additionally take a look at list of serial parameters for Mission Planner.

When using UART for telemetry please keep in mind that serial ports have default baud rates.

Reload configuration

If you changed something in the previous step you need to reload configuration for systemd to work properly.

pi@navio: ~ $ sudo systemctl daemon-reload

Starting

Now you can start ArduPilot:

pi@navio: ~ $ sudo systemctl start arducopter

To stop the service run:

pi@navio: ~ $ sudo systemctl stop arducopter

Autostarting on boot

To automatically start ArduPilot on boot you need to enable arducopter:

pi@navio: ~ $ sudo systemctl enable arducopter

To disable the autostart:

pi@navio: ~ $ sudo systemctl disable arducopter

You can check is ArduPilot already enabled or not:

pi@navio: ~ $ systemctl is-enabled arducopter

Connecting to the GCS

Mission Planner

A Windows only ground station. It is the most feature complete, though.

QGroundControl

A crossplatform ground station for Mavlink-based flight stacks (like Ardupilot).

APM Planner

APM Planner is a ground station software for ArduPilot. It can be downloaded from the ardupilot.com

APM Planner listens on UDP port 14550, so it should catch telemetry from the drone automatically.

MAVProxy

MAVProxy is a console-oriented ground station software written in Python. It’s well suited for advanced users and developers.

To install MAVProxy use Download and Installation instructions.

To run it specify the --master port, which can be serial, TCP or UDP. It also can perform data passthrough using --out option.

pi@navio: ~ $ mavproxy.py --master 192.168.1.2:14550 --console

Where 192.168.1.2 is the IP address of the GCS, not RPi.

Launching a custom ArduPilot binary

Navio is supported in ArduPilot upstream and if you'd like to build the binary yourself please proceed to the Building from sources. Also you can download the latest stable binary files from ArduPilot buildserver. To download arducopter-quad binary:

pi@navio: ~ $ wget http://firmware.eu.ardupilot.org/Copter/stable/navio2-quad/arducopter-quad
pi@navio: ~ $ chmod +x arducopter-quad

In case of use another frame type, change tail of the link. For example /navio2-hexa/arducopter-hexa. Supported vehicle types are listed below:

  • ArduRover
  • ArduPlane
  • ArduPlane-tri
  • ArduCopter-quad
  • ArduCopter-tri
  • ArduCopter-hexa
  • ArduCopter-y6
  • ArduCopter-octa
  • ArduCopter-octa-quad
  • ArduCopter-heli
  • ArduCopter-single

If you want to launch a custom binary you're expected to modify and use /etc/systemd/system/ardupilot.service

[Unit]
Description=ArduPilot for Linux
After=systemd-modules-load.service
Documentation=https://docs.emlid.com/navio2/navio-ardupilot/installation-and-running/#autostarting-ardupilot-on-boot
Conflicts=arduplane.service arducopter.service ardurover.service

[Service]
EnvironmentFile=/etc/default/ardupilot

###############################################################################
####### DO NOT EDIT ABOVE THIS LINE UNLESS YOU KNOW WHAT YOU"RE DOING #########
###############################################################################

# Uncomment and modify this line if you want to launch your own binary
#ExecStart=/bin/sh -c "/home/pi/<path>/<to>/<your>/<binary> ${ARDUPILOT_OPTS}"

##### CAUTION ######
# There should be only one uncommented ExecStart in this file

###############################################################################
######## DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU"RE DOING ########
###############################################################################

Restart=on-failure

[Install]
WantedBy=multi-user.target

The comments speak for themselves. The only thing you need to adjust is

#ExecStart=/bin/sh -c "/home/pi/<path>/<to>/<your>/<binary> ${ARDUPILOT_OPTS}"

to something like this

ExecStart=/bin/sh -c "/home/pi/arducopter-quad ${ARDUPILOT_OPTS}"

Other than that the launching procedure is no different than the one described above with the only exception that you need to use systemctl utility with ardupilot service instead of arducopter/arduplane/ardurover and use /etc/default/ardupilot for ARDUPILOT_OPTS modifications.

The command below will start custom ArduPilot binary and then mark it to launch on boot:

pi@navio: ~ sudo systemctl start ardupilot && sudo systemctl enable ardupilot