Compiling ArduCopter/ArduPilot with the Arduino IDE

Preamble

Having trouble getting the ArduPilot/ArduCopter source code (it would be rather churlish to call it a sketch) to compile? Here is an account of the issues that I encountered when I gave it a go…

The story

Follow these instructions first, Building ArduPilot for APM2.x on Windows with Arduino, to get your environment set up correctly. However, the given git instructions will only download the latest git, and for APM you need only the 3.2.1 code branch, as this is the latest version that APM supports. With the latest git you will not see the ArduCopter projects in the sketch book, because the .pde/.ino files are no longer present:

Limited menu options
Limited menu options

You can go to the github and select the 3.2.1 branch of ArduCopter,

Select ArduCopter 3.2.1 branch
Select ArduCopter 3.2.1 branch

and download

Download the .zip
Download the .zip

Then change the preferences in the Arduino IDE to point to the unzipped ArduCopter code (I unzipped mine to C:\):

Arduino IDE preferences
Arduino IDE preferences

Now the sketch will appear in the menu

ArduCopter now shows in the Sketchbook menu
ArduCopter now shows in the Sketchbook menu

but it will not compile because it thinks that AP_HAL_Boards.h is missing.

Missing AP_HAL_Boards.h
Missing AP_HAL_Boards.h

The error is

In file included from ArduCopter.pde:86:0:
C:\Users\davinci\Documents\GitHub\ardupilot\libraries\AP_Common/AP_Common.h:24:34: fatal error: AP_HAL/AP_HAL_Boards.h: No such file or directory
#include <AP_HAL/AP_HAL_Boards.h>

Although it is present

Location of AP_HAL-Boards.h
Location of AP_HAL-Boards.h

The problem is that you need to select the HAL board

Select the correct HAL board
Select the correct HAL board

But then upon closing, reopening and recompiling, the following error occurs

AP_Common.h is missing
AP_Common.h is missing

The error given is

ArduCopter.pde:86:23: fatal error: AP_Common.h: No such file or directory
compilation terminated.

Again, the file AP_Common.h is present

Location of AP_Common.h
Location of AP_Common.h

If you read the ReadMe.txt in the top level libraries directory of the ArduPilot/ArduCopter source code,

Libraries ReadMe.txt
Libraries ReadMe.txt

it states that the libraries should be installed.

For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries

You have two options:

  1. Ensure that the sketchbook in the preferences is set to point to the directory containing the ‘libraries’ directory below, i.e. ‘ardupilot-ArduCopter-3.2.1’, or;
  2. Move the contents of the “libraries” directory within the source code tree
Libraries in the ArduCopter source
Libraries in the ArduCopter source

to the “libraries” directory in the ArduPilot Arduino IDE directory,

Libraries directory of the ArduPilot Arduino IDE
Libraries directory of the ArduPilot Arduino IDE

Once those files have been moved, the “libraries” directory of the ArduPilot Arduino IDE should now look something like this,

Libraries directory of the ArduPilot Arduino IDE with the new libraries
Libraries directory of the ArduPilot Arduino IDE with the new libraries

Now it will compile, although with some warnings. However, these warnings may be ignored.

This video may also be of interest

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s