Hello everyone!
I have an issue with using Ephemeris class with constructor which takes List and TimeInterpolator. I use SpacecraftStateInterpolator as an implementation for TimeInterpolator.
The problem is, when SpacecraftStateInterpolator uses frame different from List frame there is no synchronization between frames, i.e. i have all futher states propagated (interpolated) in with wrong frame.
There is an example to reproduce this bug:
final Frame interpolatorFrame = FramesFactory.getGCRF();
final SpacecraftStateInterpolator interpolator = new SpacecraftStateInterpolator(
5,
0.001,
interpolatorFrame, // GCRF
interpolatorFrame, // GCRF
CartesianDerivativesFilter.USE_PV,
AngularDerivativesFilter.USE_R
);
final List<SpacecraftState> referenceStates = createIssStates(); // EME2000
final Ephemeris propagator = new Ephemeris(referenceStates, interpolator);
final SpacecraftState referenceState = referenceStates.getFirst();
final PVCoordinates referencePV = referenceState.getPVCoordinates();
assertThat(referenceState.getFrame()).isEqualTo(FramesFactory.getEME2000());
final Frame referenceFrame = referenceState.getFrame();
final AbsoluteDate first = referenceState.getDate();
final SpacecraftState interpolated = propagator.propagate(first);
assertThat(interpolated.getFrame()).isEqualTo(interpolatorFrame);
final PVCoordinates pv = interpolated.getPVCoordinates(referenceFrame);
// asserts bellow fail
assertThat(pv.getPosition().getX()).isEqualTo(referencePV.getPosition().getX();
assertThat(pv.getPosition().getY()).isEqualTo(referencePV.getPosition().getY();
assertThat(pv.getPosition().getZ()).isEqualTo(referencePV.getPosition().getZ();
assertThat(pv.getVelocity().getX()).isEqualTo(referencePV.getVelocity().getX();
assertThat(pv.getVelocity().getY()).isEqualTo(referencePV.getVelocity().getY();
assertThat(pv.getVelocity().getZ()).isEqualTo(referencePV.getVelocity().getZ();
private List<SpacecraftState> createIssStates() {
final double a = Constants.EGM96_EARTH_EQUATORIAL_RADIUS + 415.0 * 1e3;
final double e = 0.0003381;
final double i = Math.toRadians(51.6488);
final double raan = Math.toRadians(120.0917);
final double pa = Math.toRadians(342.2352);
final double anomaly = Math.toRadians(159.2688);
final PositionAngleType type = PositionAngleType.MEAN;
final Frame frame = FramesFactory.getEME2000();
final AbsoluteDate date = new AbsoluteDate("2014-01-01T09:46:36.000Z", TimeScalesFactory.getUTC());
final double mu = Constants.EGM96_EARTH_MU;
final KeplerianOrbit iss = new KeplerianOrbit(a, e, i, pa, raan, anomaly, type, frame, date, mu);
return List.of(
new SpacecraftState(new CartesianOrbit(iss), mu),
new SpacecraftState(new CartesianOrbit(iss).shiftedBy(60.0), mu),
new SpacecraftState(new CartesianOrbit(iss).shiftedBy(120.0), mu),
new SpacecraftState(new CartesianOrbit(iss).shiftedBy(180.0), mu),
new SpacecraftState(new CartesianOrbit(iss).shiftedBy(240.0), mu),
new SpacecraftState(new CartesianOrbit(iss).shiftedBy(300.0), mu));
}
Am I using Ephemeris class wrong?