Kalman filter usage with Matlab

Hi all, I always doubt opening a thread in the forum when I am having problems using Orekit. I tend to think that almost all use cases have already been discused here, or that the functionality is well documented, and I just don’t get it. Normally it is just a problem of me not understanding how Orekit is meant to be used, so I hope that is what is happening now.

After managing to use the BLS for orbit determination I want to get into using Kalman filters in Orekit, I think this method is better suited for my needs. Therefore, I have been reading everything I find about it:

Use of Kalman Filter for OD (general Orekit usage)
Regarding Kalman Estimator usage (Python wrapper usage)
Access to KalmanEstimation (also Python related)

I think I now have a good general idea of how it is supposed to be used. So, when you need to retrieve information from the estimation, you have to implement your own class extending a KalmanObserver, and inside the method evaluationPerformed (that the user implements there) you can do whatever you want with the KalmanEstimation information that is fed to it by the KalmanEstimator (after a measurement is added and procesed with estimationStep).

This is what I understand has to be done. In native Java I guess this is not a problem, as you just implement the class derived from KalmanObserver, instantiate it and you are done. From what I have understood of the forum threads, the Python users have a native alternative by using PythonKalmanObserver to do the same thing (I am not sure if that is still an option, it looks like there is no such file in the master branch). The problem for me is that I am trying to do this in Matlab, and maybe it is because I am not very knowlegable programing-wise, but I don’t see a way to do this observer thing from Matlab…

I know there is a way to generate classes in matlab, but I don’t think these can extend java classes (or I simply don’t know how). My current guess is that, if I want to use the Kalman estimators of Orekit in Matlab I need to learn at least a bit o Java, implement the class of KalmanObserver, compile that, and put it in the javaclass path of my Matlab instalation.

So, this post is to ask if that approach is the only possible one as Orekit is arquitected, or if I am in luck and there is a more native approach.

With this question on the table, as I think is interesting in general, I want to specify that I am looking to access the uncertainty data after each estimation is performed, as I am mainly interested in getting the estimated orbit after a radar track, but that includes state and uncertainty…

Thanks in advance. I know my questions are probably a bit naive, but I do my best to research before asking as to avoid being too much of a nuisance.

Hi @astror

That’s a good question. Unfortunately, I’m not enough familiar with Matlab to provide an answer.
Just note that KalmanObserver is optional. The Kalman estimation works properly without it.

final ProcessEstimate estimate = filter.estimationStep(KalmanEstimatorUtil.decorate(observedMeasurement, referenceDate));
            processModel.finalizeEstimation(observedMeasurement, estimate);
            if (observer != null) {
                observer.evaluationPerformed(processModel);
            }

Regards,
Bryan

1 Like

Hi @bcazabonne , thanks for the comment. I still need the information of the uncertainty after updating the orbit with the filter, so the observer is neccesary.

After watching some tutorials and learning a bit about Java I have arrived to this class:

package myOrekitUtils;

import org.orekit.estimation.sequential.KalmanEstimation;
import org.orekit.estimation.sequential.KalmanObserver;
import org.hipparchus.linear.*;

public class basicObserver implements KalmanObserver {
		
	public RealMatrix EstimatedCovariance;
	
	public basicObserver() {
		this.EstimatedCovariance = new Array2DRowRealMatrix(6,6);
	}

	@Override
	public void evaluationPerformed(KalmanEstimation estimation) {

		EstimatedCovariance = estimation.getPhysicalEstimatedCovarianceMatrix();

	}
	
}

This I have exported to a .jar file (which I leave attached in case someone is on the same page as I was), and after puting it in the javaclasspath of Matlab I can do import myOrekitUtils.basicObserver, and it works! Now I can access all the information that I may need, for now the estimated covariance is enough.

I want to use this post to also ask, in which frame is the Covariance Matrix given?. I assume that it is in the same frame of the orbit used for the PropagatorBuilder, but just in case I’ll ask.

Thanks again for the help.
myOrekitUtils.jar (1.6 KB)

Yes, it is!

Note that since Orekit 11.3 you can construct a StateCovariance object from estimation.getPhysicalEstimatedCovarianceMatrix() in order to perform frame transformation and orbit type transformation.

Bryan

1 Like

Thanks! That is actually really usefull to me, I was going to rotate this matrix to a local frame so that solves it.

Hi @astror,

Note that there is an example of a Kalman observer implemented in Java in the tutorials.
If you want some hints on how to retrieve the different quantities of the Kalman.

1 Like