Browse Source

ACM: check the return of compass.init()

if the compass fails to initialise then don't pass it to DCM, or we
will get no yaw control. Report the init failure to the user.
mission-4.1.18
Andrew Tridgell 13 years ago
parent
commit
864ed1a87f
  1. 6
      ArduCopter/sensors.pde

6
ArduCopter/sensors.pde

@ -78,8 +78,12 @@ static int32_t read_barometer(void) @@ -78,8 +78,12 @@ static int32_t read_barometer(void)
static void init_compass()
{
compass.set_orientation(MAG_ORIENTATION); // set compass's orientation on aircraft
if (!compass.init()) {
// make sure we don't pass a broken compass to DCM
Serial.println_P(PSTR("COMPASS INIT ERROR"));
return;
}
dcm.set_compass(&compass);
compass.init();
compass.get_offsets(); // load offsets to account for airframe magnetic interference
compass.null_offsets_enable();
}

Loading…
Cancel
Save