Arduino Programming issue.

Hello, I am throwing myself into some programming.

I am trying to port the AP_GPS libraries to the ArducopterNG.

I have a question for Arduino an C++ programmers. My main .pde is not compiling correctly even though I think everything looks fine.

This is the partial code:

...

#include <AP_GPS.h>

...

#define IsGPS            // Do we have a GPS connected


#ifdef IsGPS

#define GPS_PROTOCOL GPS_PROTOCOL_MTK16

AP_GPS_MTK16          GPS(&Serial1);

#endif

...

void setup() {

 

APM_init();

...

}

...

 

If I comment #define IsGPS it will not compile.

ArduPiratesNG_newGPS.cpp: In function 'void setup()':
ArduPiratesNG_newGPS:363: error: 'APM_Init' was not declared in this scope

...

If I comment #define IsGPS and I comment AP_GPS_MTK16          GPS(&Serial1); it will compile.

 

How can I put a conditional statement and define global instances?

 

BTW in ArdupilotMega it is defined like this (still will not compile for me if I put #ifdef IsGPS ... #endif):

// real GPS selection
#if GPS_PROTOCOL == GPS_PROTOCOL_NMEA
AP_GPS_NMEA        gps(&Serial1);
#elif GPS_PROTOCOL == GPS_PROTOCOL_SIRF
AP_GPS_SIRF        gps(&Serial1);
#elif GPS_PROTOCOL == GPS_PROTOCOL_UBLOX
AP_GPS_UBLOX    gps(&Serial1);
#elif GPS_PROTOCOL == GPS_PROTOCOL_MTK
AP_GPS_MTK        gps(&Serial1);
#elif GPS_PROTOCOL == GPS_PROTOCOL_MTK16
AP_GPS_MTK16    gps(&Serial1);
#elif GPS_PROTOCOL == GPS_PROTOCOL_NONE
AP_GPS_None        gps(NULL);
#else
 #error Unrecognised GPS_PROTOCOL setting.
#endif // GPS PROTOCOL

 

Any help appreciate.

Cheers

Emile

 

 

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • AP_GPS is already implemented in Arducopter NG code

    I don't know what you want to do?

This reply was deleted.

Activity