Understanding the management of Measurement in the BatchLSEstimator and the computation of residuals

Hello the team,

I’m new to Orekit. I’m currently working on an OTDS algorithm for GNSS. For orbit determination, I use the BatchLSEstimator class.

I have questions regarding the measurement and the estimator.

I would like to be sure that I understood correclty the process behind the batchLSEstimator.
I created an observedMeasurement (the raw measurement) and I defined some modifiers.
In the Estimator, the theroretical value of my observed measurement will be estimate and an EstiamtedMeasurement will be created. Then the LMS will compare this theoretical value with the current satellite positon guess and try to minimise the residuals. Residuals are computed doing the difference between the value obtained by the current position guess and the theoretical value of my measurement.

Is that rigth?

If this is rigth, I would like to know how I can have access to the residuals before and after each estimation in order to check the LMS performances. I actually know how to acces them after the estimation thanks to the BatchLSObserver but I would like to compute them also before the estimation.

Thank you in advance for your help,

Luca

Hi @luca123,

Yes!
If you want to go further, in the LMS of Orekit, the residuals and Jacobian matrix are computed in the method AbstractBatchLSModel.fetchEvaluatedMeasurement.
Here the value vector contains the weighted residuals for a given evaluation, and the jacobian matrix contains the weighted Jacobian matrix

It’s funny you’re asking that because I just sent some classes to perform residuals computation in this post.

That being said it will just give you the residuals at iteration 0 (before the LMS filter starts working towards a solution).
If you want to have them at each iteration, you will have to extract them from a BatchLSObserver
There is an example of an implementation of such an observer: OrbitDeterminationObserver in the Java tutorials.
Note that this one doesn’t save the residuals at each iteration, you will have to do this by yourself.

Method evaluationPerfomed is called after each evaluation of the filter.
In this method, the EvaluationProviders variable can be called in a loop to retrieve each EstimatedMeasurement and perform residuals’ computation (see the loop at line 121 of the example).
Then calling:

residual[i] = estimatedMeasurement.getEstimatedValue()[i] - estimatedMeasurement.getObservedValue()[i]

on each component of your observations will give you the residuals.

Usage of the observer:

// Suppose you have a fully configured BatchLSEstimator
BatchLSEstimator estimator;

// Instantiate your custom observer with inputs [my_inputs]
// Suppose your observer save the residuals at each evaluation in an internal attribute
BatchLSObserver myObserver = new MyCustomObserver([my_inputs])

// Add it to the estimator
estimator.setObserver(myObserver);

// Then estimate
estimator.estimate();

After the process of estimation, if you have saved the residuals in the observer, you will just have to extract them.

Hope this helps,
Maxime

1 Like

Thank you very much Maxime ! It really helps.

There is however still something I do not understand. Why the residuals are computed this way ?

residual[i] = estimatedMeasurement.getEstimatedValue()[i] - estimatedMeasurement.getObservedValue()[i]

Indeed, the getObservedValue() gives the raw observed measurement and not the theoretical value of the measurement. So if we compare the observed measurement with the estimation value we do not take into account all the modifers of the measurment. Is it wrong ?

I hope I express myself clearly haha.

Thanks for your help,

Luca

Hi again @luca123,

The estimated measurement is the sum of a theoretical evaluation (geometric consideration + light time correction) plus the modifiers (biases, atmospheric corrections etc.).
So the modifiers are added to the estimation, and not removed from the observation.
Does that answer your question ?

The actual code doing the sum is here, in method estimate of AbstractMeasurement class.

Hello Maxime,

Thank you, for you answer. I still do not understand why the residuals are computed this way…

We have :

(1) The observed raw value
(2) The estimated theoretical value (obtained taking into account geometrical considerations and the modifiers )
(3) The value computed from current spacecraft state
(4) The value obtained after the evaluation (that will give the new spacecraft state)

So why the residuals are not computed doing |(4) - (2)| ? Doing so would allow to compare values “after modifiers” with values “after modifiers”. In what you said earlier, the residuals are compted doing |(4)-(1)| if I understood correctly ?

Thank you again for your answers, it really helps to discuss for understanding the code :wink:

Luca

The observed value (1) is the physical measurement, it already includes geometry, modifiers and also measurements errors. So when computing residuals we have to compare it with something theoretical that corresponds to our understanding of the physics, i.e. from models. So we include the geometrical part we know of by propagating some initial state and applying equations of motions, and we include the modifiers that we know of by applying things like tropospheric effects, biases and so on. The result of this is what we call the theoretical evaluation. This is probably what you call (2).

I don’t understand what you mean by (3). (2) is already computed from the current spacecraft state, which was propagated from the current estimated state. We don’t have access to any better state, we don’t have a magic knowledge of where the satellite is, we just estimate the state at some initial time and propagate between this initial time and the current time (hence allowing the propagation parameters to kick in and compute the sensitivity of current state to these parameters, like drag for example).

I don’t understand either what you mean by (4).

1 Like

Hello,

Thank you very much ! I think I understand now.

Initially, I thought that the “estimated value” was the value of the observed measurement without all the modifiers (i.e. the geomatrical range) and that we compared it with the spacecraft state.
But reading your message, it appears I got it wrong.
The theoretical evaluation is already the value obtained from the spacecraft state and adding the modifiers… thus it is logic to compare it with the observed value.

Thank you,

Luca