AP_AHRS: give zero lat/lng and baro alt if no position yet in DCM

This commit is contained in:
Andrew Tridgell 2014-02-15 09:23:41 +11:00
parent 59a56c9b46
commit eedd88c2ec
2 changed files with 3 additions and 6 deletions

View File

@ -861,17 +861,14 @@ float AP_AHRS_DCM::get_error_yaw(void)
// dead-reckoning or GPS
bool AP_AHRS_DCM::get_position(struct Location &loc)
{
if (!_have_position) {
return false;
}
loc.lat = _last_lat;
loc.lng = _last_lng;
loc.alt = _baro.get_altitude() * 100 + _home.alt;
location_offset(loc, _position_offset_north, _position_offset_east);
if (_flags.fly_forward) {
if (_flags.fly_forward && _have_position) {
location_update(loc, degrees(yaw), _gps->ground_speed_cm * 0.01 * _gps->get_lag());
}
return true;
return _have_position;
}
// return an airspeed estimate if available

View File

@ -61,7 +61,7 @@ public:
void reset_attitude(const float &roll, const float &pitch, const float &yaw);
// dead-reckoning support
bool get_position(struct Location &loc);
virtual bool get_position(struct Location &loc);
// status reporting
float get_error_rp(void);