Help! Arduino with APM2.6

Hello,

I am Frank and I am trying to build an automated guidance system that utilizes parafoil, APM2.6, servo motors, and GPS. The basic idea is to have the unit guide the whole system to target location by pulling on the strings of the parafoil such that the system turn left or right in accordance to target location and current system location.

The problem I am facing is how to load my Arduino codes (written in C) into APM2.6. As far as I know, there is a modified version of Arduino specifically designed for ArduPilot boards. However, when I type up the codes in the modified Arduino and trys to upload it to the APM2.6, the compiler fails. (I have included the error messages at the very bottom)

The setting I am using is ArduPilot -> HAL Board -> ArduPilot Mega 2.x. Board type is Arduino Mega 2560 or Mega ADK.
The other settings are exactly as the “How to Build Ardupilot with Arduino.pdf” file found in the following link:
firmware.diydrones.com/Tools/Arduino/

The codes I have compile just fine in regular Arduino, but if I do simple servo control tests (from Arduino library) and upload it into APM2.6, I get no responses. (I attached the servo at output 1, and the code is below)
I don’t think it is a APM2.6 failure due to defect because APM2.6 responds correctly when I typed up some integer input and response code (when I input 1, the serial monitor returns 1, etc), the APM2.6 does it perfectly.
I have also made sure that the servo are receiving enough power for it to work.

So my questions are the following:
How can I get the modified Arduino to compile my codes?
Do I have to use the modified one or can I just use the regular Arduino?
If I can how can I get APM2.6 to control servo motors as well as getting GPS data through my Arduino code (because so far I got no responses)?
Can I use Mission Planner to achieve what I want it to do?
If all else fails, do I just need to get an Arduino Mega 2560 Board so that Arduino works straight up with it?

Thank you for your time and help!
I greatly appreciate it!

Sincerely,
Frank

Servo test code:
#include <Servo.h>

Servo myservo;

void setup()
{
myservo.attach(1);
}

void loop()
{
myservo.writeMicroseconds(1500);
delay(1000);

myservo.writeMicroseconds(2500);
delay(1000);
}

Error messages:
Compiling my code with modified Arduino gives me the follow error message:
“fatal error: Arduino.h: No such file or directory. Compilation terminated.”

If I include all the libraries included in ArduCopter sketchbook and then compile it, the error message is the following:
AP_HAL_AVR\AnalogIn_ADC.cpp.o: In function AP_HAL_AVR::ADCSource::voltage_average()': C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:51: undefined reference tohal’
C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:51: undefined reference to hal' AP_HAL_AVR\AnalogIn_ADC.cpp.o: In functionAP_HAL_AVR::ADCSource::set_pin(unsigned char)’:
C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:98: undefined reference to hal' C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:98: undefined reference tohal’
AP_HAL_AVR\AnalogIn_ADC.cpp.o: In function AP_HAL_AVR::ADCSource::voltage_latest()': C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:71: undefined reference tohal’
AP_HAL_AVR\AnalogIn_ADC.cpp.o:C:\GIT\ardupilot\libraries\AP_HAL_AVR/AnalogIn_ADC.cpp:71: more undefined references to `hal’ follow
collect2.exe: error: ld returned 1 exit status

I can’t answer everything because I’ve only just started working on the APM 2.6 myself, but I have been able to get the modified Arduino to compile. The issue is (as far as I understand) that the Ardupilot firmware uses its own custom core files instead of the standard core files. When you select HAL -> APM2.x, Arduino loads only the custom core files. If you want to use the standard Arduino commands, you have to select HAL -> None. I imagine it is done this way to save space (if Arduino loaded both cores, it would be too big for the board).

Also, with regards to the pin, I believe pin 1 is attached to an LED. You might want to try one of the analog out pins (you can reference them by either “A0” -> “A8” or “54” -> “62”). Apologies that I don’t have anymore pin information, if you look at my earlier post I am looking for that information as well!

Hope this helps.