Browse Source

Rover: compass set-initial-location uses ahrs location

Previously it could attempt to use a gps location even if gps was not being used
Also compass-accumulate moved to sensors.cpp
master
Randy Mackay 8 years ago
parent
commit
eb2aa80fca
  1. 10
      APMrover2/APMrover2.cpp
  2. 3
      APMrover2/Rover.h
  3. 4
      APMrover2/commands.cpp
  4. 22
      APMrover2/sensors.cpp

10
APMrover2/APMrover2.cpp

@ -235,16 +235,6 @@ void Rover::gcs_failsafe_check(void) @@ -235,16 +235,6 @@ void Rover::gcs_failsafe_check(void)
}
}
/*
if the compass is enabled then try to accumulate a reading
*/
void Rover::compass_accumulate(void)
{
if (g.compass_enabled) {
compass.accumulate();
}
}
/*
check for new compass data - 10Hz
*/

3
APMrover2/Rover.h

@ -334,6 +334,9 @@ private: @@ -334,6 +334,9 @@ private:
// true if the system time has been set from the GPS
bool system_time_set;
// true if the compass's initial location has been set
bool compass_init_location;
// The location of the previous waypoint. Used for track following and altitude ramp calculations
struct Location prev_WP;
// The location of the current/active waypoint. Used for track following

4
APMrover2/commands.cpp

@ -106,10 +106,6 @@ bool Rover::set_home(const Location& loc, bool lock) @@ -106,10 +106,6 @@ bool Rover::set_home(const Location& loc, bool lock)
// init compass declination
if (home_is_set == HOME_UNSET) {
// Set compass declination automatically
if (g.compass_enabled) {
compass.set_initial_location(loc.lat, loc.lng);
}
// record home is set
home_is_set = HOME_SET_NOT_LOCKED;

22
APMrover2/sensors.cpp

@ -1,5 +1,27 @@ @@ -1,5 +1,27 @@
#include "Rover.h"
/*
if the compass is enabled then try to accumulate a reading
also update initial location used for declination
*/
void Rover::compass_accumulate(void)
{
if (!g.compass_enabled) {
return;
}
compass.accumulate();
// update initial location used for declination
if (!compass_init_location) {
Location loc;
if (ahrs.get_position(loc)) {
compass.set_initial_location(loc.lat, loc.lng);
compass_init_location = true;
}
}
}
void Rover::init_barometer(bool full_calibration)
{
gcs_send_text(MAV_SEVERITY_INFO, "Calibrating barometer");

Loading…
Cancel
Save