# confused by robott_localization by the process of predict and correct in filter? [closed]

Hello, I am confused by the processMeasurement() function in filter_base.cpp . Both predict and correct use the same measurement ? In normal EKF, I think one measurement is used for predict, another for correct.

 // If we've had a previous reading, then go through the predict/update
// cycle. Otherwise, set our state and covariance to whatever we get
// from this measurement.
if (initialized_)
{
// Determine how much time has passed since our last measurement
delta = measurement.time_ - lastMeasurementTime_;

FB_DEBUG("Filter is already initialized. Carrying out predict/correct loop...\n"
"Measurement time is " << std::setprecision(20) << measurement.time_ <<
", last measurement time is " << lastMeasurementTime_ << ", delta is " << delta << "\n");

// Only want to carry out a prediction if it's
// forward in time. Otherwise, just correct.todo  a little confused here, both predict and correct use the same measurement ?
if (delta > 0)
{
validateDelta(delta);
predict(measurement.time_, delta);

// Return this to the user
predictedState_ = state_;//
}

correct(measurement);//
}

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by gaochao_hit close date 2019-01-29 23:39:45.698994

Sort by » oldest newest most voted

In Kalman filters, there are two stages to fusing every measurement: prediction and correction.

During the prediction stage, we predict from the current time to the time of the next measurement. The prediction uses the filter's kinematic model. Then, we correct the predicted state with the measurement data.

What you see is reflected in the code you posted. The prediction stage isn't using the measurement itself, but the measurement's _time_ (measurement.time_). Then we correct the filter with the actual measurement itself.

more

( 2018-12-10 19:04:09 -0500 )edit

@gaochao_hit would you mind accepting the answer?

( 2019-01-28 02:32:26 -0500 )edit