  using namespace EKFS;
  using namespace Eigen;
  
  ExitHandler do_exit;
  
  static VectorXd floatlist2vector(const capnp::List<float, capnp::Kind::PRIMITIVE>::Reader& floatlist) {
    VectorXd res(floatlist.size());
    for (int i = 0; i < floatlist.size(); i++) {
      res[i] = floatlist[i];
    }
 
</s> remove   this->last_gps_fix = current_time;
 </s> add   // Sanity checks
  if ((log.getVerticalAccuracy() <= 0) || (log.getSpeedAccuracy() <= 0) || (log.getBearingAccuracyDeg() <= 0)) {
    return;
  }

  if ((std::abs(log.getLatitude()) > 90) || (std::abs(log.getLongitude()) > 180) || (std::abs(log.getAltitude()) > ALTITUDE_SANITY_CHECK)) {
    return;
  }

  if (floatlist2vector(log.getVNED()).norm() > TRANS_SANITY_CHECK){
    return;
  } </s> remove       this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_GYRO, { Vector3d(-v[2], -v[1], -v[0]) });
 </s> add       auto meas = Vector3d(-v[2], -v[1], -v[0]);
      if (meas.norm() < ROTATION_SANITY_CHECK) {
        this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_GYRO, { meas });
      } </s> remove       this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_ACCEL, { Vector3d(-v[2], -v[1], -v[0]) });
 </s> add       auto meas = Vector3d(-v[2], -v[1], -v[0]);
      if (meas.norm() < ACCEL_SANITY_CHECK) {
        this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_ACCEL, { meas });
      } </s> remove       msg.gpsLocationExternal.verticalAccuracy = 0.0
 </s> add       msg.gpsLocationExternal.verticalAccuracy = 1.0
      msg.gpsLocationExternal.speedAccuracy = 1.0
      msg.gpsLocationExternal.bearingAccuracyDeg = 1.0
const double ACCEL_SANITY_CHECK = 100.0;  // m/s^2
const double ROTATION_SANITY_CHECK = 10.0;  // rad/s
const double TRANS_SANITY_CHECK = 200.0;  // m/s
const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg)
const double ALTITUDE_SANITY_CHECK = 10000; // m
const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad
  using namespace EKFS;
  using namespace Eigen;
  
  ExitHandler do_exit;
const double ACCEL_SANITY_CHECK = 100.0;  // m/s^2
const double ROTATION_SANITY_CHECK = 10.0;  // rad/s
const double TRANS_SANITY_CHECK = 200.0;  // m/s
const double CALIB_RPY_SANITY_CHECK = 0.5; // rad (+- 30 deg)
const double ALTITUDE_SANITY_CHECK = 10000; // m
const double MIN_STD_SANITY_CHECK = 1e-5; // m or rad
  
  static VectorXd floatlist2vector(const capnp::List<float, capnp::Kind::PRIMITIVE>::Reader& floatlist) {
    VectorXd res(floatlist.size());
    for (int i = 0; i < floatlist.size(); i++) {
      res[i] = floatlist[i];
    }
keep keep keep add keep keep keep keep keep keep
 Locationd input sanity checks (#20845)

* Add first sanity checks on inputs

* more gps checks

* make sure test values pass sanity checks

* this localizer supports cannonball runs

Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com> 
selfdrive/locationd/locationd.cc