Interpolation of additional state for SpacecraftState

Hi all,

I had a question regarding additional states attached to a SpacecraftState object and more precisely to the carrying out of the information when transforming an ArrayList<SpacecraftState> into a BoundedPropagator.

Using an external trajectory file, I get the orbital parameters and the thrust generated on each time step to generate a set of SpacecraftState. To have all the information correctly synchronized I was hoping to use additional states to carry the information of the thrust. But when using the BoundedPropagator, the additional states seem to have been erased.

Is there a better way to carry this thrust information?

See below for the code I’m using to create the ArrayList<SpacecraftState> and how I transform it to a BoundedPropagator.

public static ArrayList<SpacecraftState> readTrajectoryFile(File file) throws IOException{

// Array containing all spacecraft states
ArrayList<SpacecraftState> spacecraftStates = new ArrayList<SpacecraftState>();

[...]	

while ((line = reader.readLine()) != null) {

[...]
// Get thrust
thrust = Double.parseDouble(columns[19]);

try {
// Add spacecraft state and convert to J2000
	Transform cirfToJ2000 = frame.getTransformTo(frameJ2000, date);
	KeplerianOrbit orbitJ2000 = new KeplerianOrbit(cirfToJ2000.transformPVCoordinates(keplerianOrbit.getPVCoordinates()), frameJ2000, mu);
	spacecraftStates.add(new SpacecraftState(orbitJ2000).addAdditionalState("thrust", thrust));
} catch (OrekitException e1) {
	logger.error("Orekit error, failed to build SpacecraftState", e);
}
}
reader.close();
return spacecraftStates;

Once this ArrayList<SpacecraftState> is created I then transform it into a BoundedPropagator:

ephemerisReference = new Ephemeris(ephemerisT3D, 3);

Thank you very much for your help!

Kind regards,

B.

Hi Benoist,

That is weird, the Ephemeris class should handle additional states.
Could you provide us with a working example showing your issue, like a failing JUnit test ?

Regards,
Maxime

Hi Maxime,

I actually just managed to spot where the state gets erased. I checked and as you said when I’m out of the method reading my external file the state does exist. But it is when I add an attitude provider to the ephemeris that the state is erased.

To debug I simply tested:

// Set attitude
logger.info("{}", ephemerisReference.propagate(ephemerisReference.getMaxDate().shiftedBy(-1)).getAdditionalStates());
ephemerisReference.setAttitudeProvider(attitudeReference);
logger.info("{}", ephemerisReference.propagate(ephemerisReference.getMaxDate().shiftedBy(-1)).getAdditionalStates());
System.exit(0);

For which I get:

10:31:12.818 [main] INFO  main.MA_Propagator - {thrust=[D@64f6106c}
10:31:12.819 [main] INFO  main.MA_Propagator - {}

Is there a way to not erase the states when adding an attitude provider?

Otherwise I’ll just use two separate variables as attitude and trajectories are independent - they both are coming from an external file.

Thank you very much for your help!

Kind regards,

B.

Hi again Benoist,

I think you found a bug. Thank you for this !
Could you please open an issue on the Gitlab forge ?

The bug is in Ephemeris#basicPropagate (l.222).
Line:

return new SpacecraftState(evaluatedState.getOrbit(), calculatedAttitude, evaluatedState.getMass());

Should be:

return new SpacecraftState(evaluatedState.getOrbit(), calculatedAttitude, evaluatedState.getMass(), , evaluatedState.getAdditionalStates());

In short, the additional state is “forgotten” when adding the evaluated attitude.

Regards,
Maxime

Ah okay, no worries! I just opened an issue with your recommendation and a link to this topic for reference.

Thank you!

B.

Thanks!

The fix will be provided asap.
If you want and have time you can also contribute it, following guidelines from the contributing guide :wink:
Have a good day.