APM autopilot

By default, Debian image has a service which consists on running the autopilot endelessly. If you execute the command top, you'll see the next tasks are running:

Where ArduCopter.elf and apm-startup.sh are part of that service.


Notice that the default autopilot frame launched is quad-frame


If you wish to stop the APM Autopilot, please execute:

systemctl stop apm-copter.service

If you wish to start the APM Autopilot, please execute:

systemctl start apm-copter.service

If you wish to disable the APM Autopilot service, meaning that will not execute on boot any longer, please execute:

systemctl disable apm-copter.service

If you wish to enable the APM Autopilot service, meaning that will execute on boot, please execute:

systemctl enable apm-copter.service

If you wish to check the status/obtain info about the APM Autopilot service, please execute:

systemctl status apm-copter.service

The autopilot is launched by a script that is located at:

/etc/init.d/

that is called apm4-startup.sh. Editing this file between the lines 74 and 81, you could select how to execute the autopilot, the options are:

./<ArduCopter_executable_name.elf> -A <primary_telemetry_port> -B <GPS_port> -C <secondary_telemetry_port>

The next lines shows the most used cases:

#Launch ArduCopter.elf excutable, send data through USB connection (192.168.7.1) and attach GPS to port ttyo5
./ArduCopter.elf -A udp:192.168.7.1:6000 -B /dev/ttyO5

#Launch hexa frame ArduCopter.elf excutable, send data through WiFi connection (11.0.0.2) and attach GPS to port ttyo5
./ArduCopter_hexa.elf -A udp:10.0.0.2:6000 -B /dev/ttyO5

#Launch ArduPlane.elf excutable, send data through MAVROS bridge (127.0.0.1) and attach GPS to port ttyo5
./ArduPlane.elf -A udp:127.0.0.1:6001 -B /dev/ttyO5

#Launch Rover autopilot, use USB0 us telemetry port and WiFi as secondary telemtry port
#Use GPS located at ttyo5
./ArduRover.elf -A /dev/ttyUSB0 -B /dev/ttyO5 -C udp:10.0.0.2:6000

Notice that the executables (Ardu<>.elf) has to be located under the home folder (/~)

Every time the autopilot is armed, a new fly log is stored containing information about the flight. This logs are stored in:

/var/APM/logs

This folder contains a textfile called "LASTLOG.TXT" that points out which flylog has been created the last. If you execute cat LASTLOG.txt the name of this last log will be displayed.

If you wish to analyze the content of one flight, just download and open it using a log analyzer, i.e., APM Planner 2.0 has a log viewer or you could use MAVProxy tools

To download a log, execute in your Linux/MacOS computer:

          ##  miniUSB  ##   /  ## WiFi ##
scp root@{192.168.7.2:6000}/{10.0.0.2:7000}:/var/APM/logs/<log_number>.BIN <path/to/destiny_folder_computer>

What if the autopilot is not launched? You can check what's going on having a look into the error log. Check it using: cat ~/logs/copter.log

If you want to have the latest version of the autopilot, or you want to have the binary for another frame/vehicle, you need to compile the source.

Follow the next steps:

Get access to Internet, plug a Ethernet into RJ-45 and give access to the net:

#Upload eth0 interface
ifconfig eth0 up
#give internet to eth0
dhclient eth0
#check it
ping www.google.com
#press |ctrl| |c| to finish

Now clone the source code

cd ~/
git clone https://github.com/erlerobot/ardupilot.git

Finally compile, here some examples

To compile ArduCopter

cd ~/ardupilot/ArduCopter
make pxf
#ArduCopter.elf is generated in this folder
#move it to ~/ to execute it

To compile ArduCopter hexa frame

cd ~/ardupilot/ArduCopter
make pxf-hexa
#ArduCopter.elf is generated in this folder
#move it to ~/ to execute it

To compile ArduPlane

cd ~/ardupilot/ArduPlane
make pxf
#ArduPlane.elf is generated in this folder
#move it to ~/ to execute it