Unscented Kalman Filter with SGP4 Propagator

It is a library like Orekit. You can access the hipparchus .jar just here.
All the .jar are contained inside the downloaded .zip.

Bryan

Bryan,

Yep I ran into that library thank you. I have the algorithm done, however I am running into an issue with the stateToTLE function. I get the following error on matlab:

org.orekit.errors.OrekitIllegalStateException: orbit not defined, state rather contains an absolute position-velocity-acceleration

This is my code:

positionJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,1),x_hatJ(j,2),x_hatJ(j,3));
velocityJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,4),x_hatJ(j,5),x_hatJ(j,6));
pvCoordsJ = org.orekit.utils.AbsolutePVCoordinates(inertialFrame,TLEs{1,i-1}.getDate(),positionJ,velocityJ);
stateJ = org.orekit.propagation.SpacecraftState(pvCoordsJ);
TLEJ = org.orekit.propagation.analytical.tle.TLE.stateToTLE(stateJ,TLEs{1,i-1});

x_hatJ is a matrix where each row is a 1x6 PV state,TLEs is a structure where each cell is a TLE. From what I found throughout the orekit classes list, the declaration is fine. In fact there are no errors until I get to the TLEJ definition. On the method definition, it says I can pass a spacecraftState and a TLE template.

PS: For reference, x_hatJ is a slightly perturbed version of a TLEs state, so I am using that same TLE as a guess for the template as it should be fairly close.

Thank you, Franco

Hi Franco,

I’ve not checked myself, but if what you say is right, the documentation is misleading at best. There are two ways to create a SpacecraftState basically. The one expected here is with an Orbit, not an AbsolutePVCoordinates. So you need to build an intermediate object, for example CartesianOrbit, with your PVCoordinates. You’ll also need to pass a gravitational constant for the central body (that’s the main difference with the other option). There are many examples of this across tutorials and tests.

Cheers,
Romain.

Romain,

Thank you for replying back. I did see the option to create a SpacecraftState with an Orbit object instead, and I tried it. I actually tried CartesianOrbit as you mentioned above, however it seems the SpacecraftState constructor doesn’t like it if I use CartesianOrbit instead of Orbit. And for some reason matlab isn’t recognizing “org.orekit.orbits.Orbit” if I construct it as Orbit(PVCoordinates,Frame,mu) as per the documentation. See below my code for CartesianOrbit, including the error showing up when constructing “stateJ”. Any tips to solve this issue?

positionJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,1),x_hatJ(j,2),x_hatJ(j,3));
velocityJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,4),x_hatJ(j,5),x_hatJ(j,6));
pvCoordsJ = org.orekit.utils.TimeStampedPVCoordinates(TLEs{1,i-1}.getDate(),positionJ,velocityJ);
orbitJ = org.orekit.orbits.CartesianOrbit(pvCoordsJ,inertialFrame,TLEs{1,i-1}.getDate(),mu);
stateJ = org.orekit.propagation.SpacecraftState(orbitJ);

Java exception occurred:
java.lang.NoSuchMethodError: org.hipparchus.geometry.euclidean.threed.Vector3D.normalize()Lorg/hipparchus/geometry/euclidean/threed/Vector3D;
at org.orekit.orbits.CartesianOrbit.shiftPVElliptic(CartesianOrbit.java:449)
at org.orekit.orbits.CartesianOrbit.shiftedBy(CartesianOrbit.java:392)
at org.orekit.orbits.CartesianOrbit.shiftedBy(CartesianOrbit.java:74)
at org.orekit.orbits.Orbit.getPVCoordinates(Orbit.java:442)
at org.orekit.attitudes.LofOffset.getAttitude(LofOffset.java:121)
at org.orekit.propagation.SpacecraftState.(SpacecraftState.java:118)

Thank you, Franco

Hello again,

Orbit is an abstract class in Java so you can’t instantiate it directly. Looks like your CartesianOrbit itself is working though, it’s when you pass it in the constructor of SpacecraftState that it crashes. I’ll need to look at the code (which I can’t do just know), but it seems that it tries to propagate and encounters a vector normalization issue

Cheers,
Romain.

Romain,

That makes sense to me. I’ll keep working on it in the meantime, maybe I can try a different orbit type and see if I run into similar issues.

Thank you, Franco

Ok so it’s the default AttitudeProvider via getAtittude that causes that propagation (of null duration though). Could you post here your numerical PVCoordinates? It looks like they’re causing an error when some Rotation is applied.

To avoid the call to getAttitude, you can pass yourself an Attitude to the Spacecraft constructor. It doesn’t really matter how you build it, as I’m guessing it doesn’t matter for your application.

Cheers,
Romain.

Romain,

Here is my timeStampedPVCoordinates object:
{2023-09-17T06:26:12.586272, P(6700696.066328449, 43189.05874969448, -15347.007707754849), V(10.277247215230117, 671.0190199629811, 7683.686980771634), A(0.0, 0.0, 0.0)}

I tried passing it a NadirPointing attitude but it does not recognize the method signature. I am using the snippet below, only adding an additional component to the SpacecraftState constructor as follows:
org.orekit.attitudes.NadirPointing(inertialFrame, earth)

Thank you,
Franco

Hi Franco,

NadirPointing is an AttitudeProvider (just like LofOffset), not an Attitude, so you’ll have the same problem (you’ll need to call getAttitude before passing it as argument for SpacecraftState and you should get the same error as before). What you need to do is build an Attitude object. You’ll see examples of how to instantiate one in the Java unit tests. One way is to pass a frame and a TimeStampedAngularCoordinates.

Best,
Romain.

Coming back to the error with CartesianOrbit, I just realized that it’s a NoSuchMethodException. So basically normalize was not found by MATLAB for Vector3D. Not sure why that happens, but I don’t think it has anything to do with the Java code. Could be that it’s defined as default in the parent interface. There’s trouble with that sort of stuff in the python wrapper.

Romain,

I did what you mentioned here, however I came up with the same error as without using attitude. See below my code and the error:

    positionJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,1),x_hatJ(j,2),x_hatJ(j,3));

    velocityJ = org.hipparchus.geometry.euclidean.threed.Vector3D(x_hatJ(j,4),x_hatJ(j,5),x_hatJ(j,6));

    pvCoordsJ = org.orekit.utils.AbsolutePVCoordinates(inertialFrame,TLEs{1,i-1}.getDate(),positionJ,velocityJ);

    angularRateJ = org.orekit.utils.TimeStampedAngularCoordinates(TLEs{1,i-1}.getDate(),pvCoordsJ,pvCoordsJ);

    attitudeJ = org.orekit.attitudes.Attitude(inertialFrame, angularRateJ);

    stateJ = org.orekit.propagation.SpacecraftState(pvCoordsJ,attitudeJ);

    TLEJ = org.orekit.propagation.analytical.tle.TLE.stateToTLE(stateJ,TLEs{1,i-1});

Java exception occurred:
org.orekit.errors.OrekitIllegalStateException: orbit not defined, state rather contains an absolute position-velocity-acceleration

at org.orekit.propagation.SpacecraftState.getOrbit(SpacecraftState.java:810)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:780)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:757)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:731)

I am also getting some warnings when importing hipparchus that may be of use, but this is new when I added the attitude:

Warning: Objects of org/orekit/errors/OrekitIllegalStateException class exist - not clearing java

Thank you,
Franco

The error is because you’re building SpacecraftState with AbsolutePVCoordinates again. You should use the CartesianOrbit, but with your user defined Attitude. You might be getting confused between AngularCoordinates and PVCoordinates. The latter has nothing to do with construction of Attitude. Not sure I’m clear. I’ll try to write you a Java example tomorrow.

Romaine,

I see your point. I changed the code appropriately and no longer have an error due to the method signature, but due to the normalization issue you mentioned previously.

java.lang.NoSuchMethodError: org.hipparchus.geometry.euclidean.threed.Vector3D.normalize()Lorg/hipparchus/geometry/euclidean/threed/Vector3D;

at org.orekit.orbits.EquinoctialOrbit.<init>(EquinoctialOrbit.java:267)

at org.orekit.propagation.analytical.tle.TLE.convert(TLE.java:861)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:780)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:757)

at org.orekit.propagation.analytical.tle.TLE.stateToTLE(TLE.java:731)

Hi Franco,

It really looks like your code doesn’t know where to find the normalize method for Vector3D, which is pure Hipparchus’ stuff. I’ve never used Orekit in MATLAB so I can’t really help here. Has anyone ever encountered such problems with the wrapper?

Best,
Romain.

Romain,

That is indeed strange. I can invoke both the getNorm() and normalize() methods manually with no problems. Could it be that hipparchus updated the method signatures and the stateToTLE method has outdated signatures?

If it helps, I am using the following jars:

hipparchus-core-3.0.jar’;
hipparchus-fitting-3.0.jar’;
hipparchus-optim-3.0.jar’;
hipparchus-geometry-3.0.jar’;

Romain,

I’m going to open a dedicated thread to this issue and hope someone has experienced something similar.

1 Like