Bug when adding AttitudeProvider to BoundedPropagator defined with AbsPVA?

Hi all,

I think there is a little bug when adding an AttitudeProvider to a BoundedPropagator defined with AbsolutePVCoordinates and not Orbit. When asking for the initial state (ephemerisReference.getInitialState()) before adding the attitude I get sthg:

SpacecraftState{orbit=null, attitude=org.orekit.attitudes.Attitude@3b084709, mass=1000.0, additional={}}

But when I add the attitude prior to this line it crashes with the following error:

orbit not defined, state rather contains an absolute position-velocity-acceleration

I don’t know of this bug still exists or has been taken care of, but if you confirm I open an issue on Gitlab.

Thank you!

B.

Hi @benoist

Indeed, Ephemeris class cannot be used with AbsolutePVCoordinates if an attitude provider is set. The reason is in basicPropagate(...) method because the new SpacecraftState is built with an Orbit and not with AbsolutePVCoordinates.

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

As this orbit is null, the getOrbit(...) method throw an OrekitException. I think this can be corrected.

Can you open an issue on Gitlab ?

Regards,
Bryan

Here a test for this issue:

@Test
public void testNullOrbit() {

    AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01),
            TimeComponents.H00,
            TimeScalesFactory.getUTC());

    Frame inertialFrame = FramesFactory.getEME2000();

    AbsoluteDate finalDate = new AbsoluteDate(new DateComponents(2004, 01, 02),
             TimeComponents.H00,
             TimeScalesFactory.getUTC());

    AbsolutePVCoordinates initPV = new AbsolutePVCoordinates(inertialFrame,
                                                             new TimeStampedPVCoordinates(initDate,
                                                                                          new PVCoordinates(new Vector3D(-29536113.0, 30329259.0, -100125.0),
                                                                                                            new Vector3D(-2194.0, -2141.0, -8.0))));
    // Input parameters
    int numberOfInterals = 1440;
    double deltaT = finalDate.durationFrom(initDate)/((double)numberOfInterals);

    // Build the list of spacecraft states
    List<SpacecraftState> states = new ArrayList<SpacecraftState>(numberOfInterals + 1);
    for (int j = 0; j<= numberOfInterals; j++) {
        states.add(new SpacecraftState(initPV).shiftedBy(j * deltaT));
    }

    // Build the epemeris propagator
    Ephemeris ephemPropagator = new Ephemeris(states, 2);

    // Get initial state 
    SpacecraftState initialState = ephemPropagator.getInitialState();
    Assert.assertEquals(0.0, Vector3D.distance(initialState.getAbsPVA().getPosition(), initPV.getPosition()), 1.0e-10);
    Assert.assertEquals(0.0, Vector3D.distance(initialState.getAbsPVA().getVelocity(), initPV.getVelocity()), 1.0e-10);

    // Set an attitude provider
    ephemPropagator.setAttitudeProvider(new LofOffset(inertialFrame, LOFType.VVLH));

    SpacecraftState finalState = ephemPropagator.getInitialState();

}

Issue can be fixed by checking if the orbit is defined:

        // Ensure that the orbit is defined
        if (evaluatedState.isOrbitDefined()) {
            return new SpacecraftState(evaluatedState.getOrbit(), calculatedAttitude,
                                       evaluatedState.getMass(), evaluatedState.getAdditionalStates());
        } else {
            return new SpacecraftState(evaluatedState.getAbsPVA(), calculatedAttitude,
                                       evaluatedState.getMass(),  evaluatedState.getAdditionalStates());
        }

Issue opened :slightly_smiling_face:

Thank you!

B.

1 Like