@ -180,6 +180,7 @@ void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) {
fix . setPosenetOK ( ! ( std_spike & & this - > car_speed > 5.0 ) ) ;
fix . setPosenetOK ( ! ( std_spike & & this - > car_speed > 5.0 ) ) ;
fix . setDeviceStable ( ! this - > device_fell ) ;
fix . setDeviceStable ( ! this - > device_fell ) ;
fix . setExcessiveResets ( this - > reset_tracker > MAX_RESET_TRACKER ) ;
fix . setExcessiveResets ( this - > reset_tracker > MAX_RESET_TRACKER ) ;
fix . setTimeToFirstFix ( std : : isnan ( this - > ttff ) ? - 1. : this - > ttff ) ;
this - > device_fell = false ;
this - > device_fell = false ;
//fix.setGpsWeek(this->time.week);
//fix.setGpsWeek(this->time.week);
@ -529,6 +530,9 @@ void Localizer::time_check(double current_time) {
if ( std : : isnan ( this - > last_reset_time ) ) {
if ( std : : isnan ( this - > last_reset_time ) ) {
this - > last_reset_time = current_time ;
this - > last_reset_time = current_time ;
}
}
if ( std : : isnan ( this - > first_valid_log_time ) ) {
this - > first_valid_log_time = current_time ;
}
double filter_time = this - > kf - > get_filter_time ( ) ;
double filter_time = this - > kf - > get_filter_time ( ) ;
bool big_time_gap = ! std : : isnan ( filter_time ) & & ( current_time - filter_time > 10 ) ;
bool big_time_gap = ! std : : isnan ( filter_time ) & & ( current_time - filter_time > 10 ) ;
if ( big_time_gap ) {
if ( big_time_gap ) {
@ -700,6 +704,11 @@ int Localizer::locationd_thread() {
bool gpsOK = this - > is_gps_ok ( ) ;
bool gpsOK = this - > is_gps_ok ( ) ;
bool sensorsOK = sm . allAliveAndValid ( { " accelerometer " , " gyroscope " } ) ;
bool sensorsOK = sm . allAliveAndValid ( { " accelerometer " , " gyroscope " } ) ;
// Log time to first fix
if ( gpsOK & & std : : isnan ( this - > ttff ) & & ! std : : isnan ( this - > first_valid_log_time ) ) {
this - > ttff = std : : max ( 1e-3 , ( sm [ trigger_msg ] . getLogMonoTime ( ) * 1e-9 ) - this - > first_valid_log_time ) ;
}
MessageBuilder msg_builder ;
MessageBuilder msg_builder ;
kj : : ArrayPtr < capnp : : byte > bytes = this - > get_message_bytes ( msg_builder , inputsOK , sensorsOK , gpsOK , filterInitialized ) ;
kj : : ArrayPtr < capnp : : byte > bytes = this - > get_message_bytes ( msg_builder , inputsOK , sensorsOK , gpsOK , filterInitialized ) ;
pm . send ( " liveLocationKalman " , bytes . begin ( ) , bytes . size ( ) ) ;
pm . send ( " liveLocationKalman " , bytes . begin ( ) , bytes . size ( ) ) ;