Bug with BoundedPropagatorView and additional states

Hi everyone,

I think there is a bug with additional states in the AbstractAnalyticalPropagator.BoundedPropagatorView.
I want to use the KeplerianPropagator with a SpacecraftState containing an additional state.
The propagation has no problem, and the final state contains the additional state. However, the generated ephemeris created by the KeplerianPropagator has a strange behaviour.
By calling the method getInitialState on the generated BoundedPropagator, we obtain the same as the initial state of the KeplerianPropagator, but the final state, after propagation, loses its additional state.
By using debug on the BoundedPropagatorView, we can find that the initialState is null, but this$0.initialState is the correct initial state. The second one is called by the getInitialState or the resetInitialState methods, but the first one is used in AbstractPropagator.initializePropagation, a method that looks for additional states. Thus, AbstractPropagator is looking at the wrong (and null) additional state.

Here is a test to reproduce this case:

    @Test
    public void testEphemerisModeWithHandler() {
        double mu = 3.9860047e14;
        AbsoluteDate initDate = AbsoluteDate.GPS_EPOCH;
        Orbit ic = new KeplerianOrbit(6378137 + 500e3, 1e-3, 0, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getGCRF(), initDate, mu);
        Propagator propagator = new KeplerianPropagator(ic);
         SpacecraftState initialState = propagator.getInitialState().addAdditionalState("myState", 4.2);
        propagator.resetInitialState(initialState);
        AbsoluteDate end = initDate.shiftedBy(90 * 60);
        propagator.setEphemerisMode();
        SpacecraftState finalStateKeplerianPropagator = propagator.propagate(end);
        BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
        SpacecraftState ephemerisInitialState = ephemeris.getInitialState();
        SpacecraftState finalStateBoundedPropagator = ephemeris.propagate(end);
        finalStateKeplerianPropagator.getAdditionalState("myState");
        ephemerisInitialState.getAdditionalState("myState");
        finalStateBoundedPropagator.getAdditionalState("myState");
    }

Do you think it is an issue, or am I using the propagator wrong ?

Regards,

Valérian

Hi Valérian,

It is definitely a bug. Could you open an issue, I’ll look at it immediately.

OK, I have solved the problem, thanks for the analysis, it helped a lot!

There were indeed three occurrences of initialState: one from KeplerianPropagator, one from the AbstractPropagator inherited by KeplerianPropagator, and one from the AbstractPropagator inherited by BoundedPropagatorView, so there are two different problems involved.

I’ll take care to open the issue and push the fix.

Issue 814 created.

Thank you for your prompt response !

It is now fixed in the develop branch.
Beware that this branch include a big change since yesterday, related to step handling,
so you may need to port the commit back to an earlier version if you can’t upgrade now.

Thank you, I will do that.