|
|
@ -64,12 +64,14 @@ bool Ekf::collect_gps(uint64_t time_usec, struct gps_message *gps) |
|
|
|
double lat = gps->lat / 1.0e7; |
|
|
|
double lat = gps->lat / 1.0e7; |
|
|
|
double lon = gps->lon / 1.0e7; |
|
|
|
double lon = gps->lon / 1.0e7; |
|
|
|
map_projection_init_timestamped(&_pos_ref, lat, lon, _time_last_imu); |
|
|
|
map_projection_init_timestamped(&_pos_ref, lat, lon, _time_last_imu); |
|
|
|
|
|
|
|
|
|
|
|
// if we are already doing aiding, corect for the change in posiiton since the EKF started navigating
|
|
|
|
// if we are already doing aiding, corect for the change in posiiton since the EKF started navigating
|
|
|
|
if (_control_status.flags.opt_flow || _control_status.flags.gps) { |
|
|
|
if (_control_status.flags.opt_flow || _control_status.flags.gps) { |
|
|
|
double est_lat, est_lon; |
|
|
|
double est_lat, est_lon; |
|
|
|
map_projection_reproject(&_pos_ref, -_state.pos(0), -_state.pos(1), &est_lat, &est_lon); |
|
|
|
map_projection_reproject(&_pos_ref, -_state.pos(0), -_state.pos(1), &est_lat, &est_lon); |
|
|
|
map_projection_init_timestamped(&_pos_ref, est_lat, est_lon, _time_last_imu); |
|
|
|
map_projection_init_timestamped(&_pos_ref, est_lat, est_lon, _time_last_imu); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Take the current GPS height and subtract the filter height above origin to estimate the GPS height of the origin
|
|
|
|
// Take the current GPS height and subtract the filter height above origin to estimate the GPS height of the origin
|
|
|
|
_gps_alt_ref = 1e-3f * (float)gps->alt + _state.pos(2); |
|
|
|
_gps_alt_ref = 1e-3f * (float)gps->alt + _state.pos(2); |
|
|
|
_NED_origin_initialised = true; |
|
|
|
_NED_origin_initialised = true; |
|
|
|