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…
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:
You can go to the github and select the 3.2.1 branch of ArduCopter,
Then change the preferences in the Arduino IDE to point to the unzipped ArduCopter code (I unzipped mine to C:\):
Now the sketch will appear in the menu
but it will not compile because it thinks that AP_HAL_Boards.h is missing.
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
The problem is that you need to select the HAL board
But then upon closing, reopening and recompiling, the following error occurs
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
If you read the ReadMe.txt in the top level libraries directory of the ArduPilot/ArduCopter source code,
it states that the libraries should be installed.
For information on installing libraries, see: http://arduino.cc/en/Guide/Libraries
You have two options:
- 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;
- Move the contents of the “libraries” directory within the source code tree
to the “libraries” directory in the ArduPilot Arduino IDE directory,
Once those files have been moved, the “libraries” directory of the ArduPilot Arduino IDE should now look something like this,
Now it will compile, although with some warnings. However, these warnings may be ignored.
This video may also be of interest