Rover: add init_compass method

no functional change
This commit is contained in:
Randy Mackay 2017-06-07 10:28:34 +09:00
parent eb2aa80fca
commit a07920c5b2
3 changed files with 18 additions and 9 deletions

View File

@ -415,6 +415,7 @@ private:
void update_trigger(void); void update_trigger(void);
void update_alt(); void update_alt();
void gcs_failsafe_check(void); void gcs_failsafe_check(void);
void init_compass(void);
void compass_accumulate(void); void compass_accumulate(void);
void compass_cal_update(void); void compass_cal_update(void);
void update_compass(void); void update_compass(void);

View File

@ -1,5 +1,20 @@
#include "Rover.h" #include "Rover.h"
// initialise compass
void Rover::init_compass()
{
if (!g.compass_enabled) {
return;
}
if (!compass.init()|| !compass.read()) {
cliSerial->printf("Compass initialisation failed!\n");
g.compass_enabled = false;
} else {
ahrs.set_compass(&compass);
}
}
/* /*
if the compass is enabled then try to accumulate a reading if the compass is enabled then try to accumulate a reading
also update initial location used for declination also update initial location used for declination

View File

@ -145,15 +145,8 @@ void Rover::init_ardupilot()
log_init(); log_init();
#endif #endif
if (g.compass_enabled == true) { // initialise compass
if (!compass.init()|| !compass.read()) { init_compass();
cliSerial->printf("Compass initialisation failed!\n");
g.compass_enabled = false;
} else {
ahrs.set_compass(&compass);
// compass.get_offsets(); // load offsets to account for airframe magnetic interference
}
}
// initialise sonar // initialise sonar
init_sonar(); init_sonar();