diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fe74ad6b16dc1876424e703a1dd4c737f90977a2..39f4d9093b68541f158c4b089cbfc80b0894f75e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -21,6 +21,10 @@
+
+ Fix the bug of attitude transition if a reset occurs during the transition
+ by adding margins to the reset of TimeSpanMap to keep the one corresponding to the "after" attitude law.
+
Generalized the GPSPropagator class to handle all GNSS constellations using
the same algorithm.
diff --git a/src/main/java/org/orekit/attitudes/AttitudesSequence.java b/src/main/java/org/orekit/attitudes/AttitudesSequence.java
index 850e59806a7d6f4ed60618b0996d76baff01e5d4..9b565954d3dcdad86add2c3879db1d6a30c3d309 100644
--- a/src/main/java/org/orekit/attitudes/AttitudesSequence.java
+++ b/src/main/java/org/orekit/attitudes/AttitudesSequence.java
@@ -387,9 +387,9 @@ public class AttitudesSequence implements AttitudeProvider {
if (activated.getTransitions().size() > 1) {
// remove transitions that will be overridden during upcoming propagation
if (forward) {
- activated = activated.extractRange(AbsoluteDate.PAST_INFINITY, s0.getDate());
+ activated = activated.extractRange(AbsoluteDate.PAST_INFINITY, s0.getDate().shiftedBy(transitionTime));
} else {
- activated = activated.extractRange(s0.getDate(), AbsoluteDate.FUTURE_INFINITY);
+ activated = activated.extractRange(s0.getDate().shiftedBy(-transitionTime), AbsoluteDate.FUTURE_INFINITY);
}
}
diff --git a/src/test/java/org/orekit/attitudes/AttitudesSequenceTest.java b/src/test/java/org/orekit/attitudes/AttitudesSequenceTest.java
index b3a722812d6f1e3ea59d45cf39d57768632fbae9..a0154202c22e28786a31a1ec4995bbe4ca1c9b2b 100644
--- a/src/test/java/org/orekit/attitudes/AttitudesSequenceTest.java
+++ b/src/test/java/org/orekit/attitudes/AttitudesSequenceTest.java
@@ -442,6 +442,9 @@ public class AttitudesSequenceTest {
}
+ /**
+ * this test have been completed to test the issue 552 fix
+ */
@Test
public void testResetDuringTransitionForward() {
// Initial state definition : date, orbit
@@ -487,6 +490,7 @@ public class AttitudesSequenceTest {
// check that if we restart a forward propagation from an intermediate state
// we properly get an interpolated attitude despite we missed the event trigger
+
final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
SpacecraftState state = propagator.propagate(midTransition.shiftedBy(-60), midTransition);
Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
@@ -495,7 +499,27 @@ public class AttitudesSequenceTest {
Assert.assertEquals(0.5 * reorientationAngle,
Rotation.distance(state.getAttitude().getRotation(), nadirR),
0.03 * reorientationAngle);
-
+
+ // check that if we restart a forward propagation from an intermediate state
+ // we properly get the "after" attitude law despite we missed the event trigger
+ // This check have been added to the test after the issue #552 fix
+
+ final AbsoluteDate afterTransition = midTransition.shiftedBy(transitionTime);
+ state = propagator.propagate(midTransition, afterTransition);
+ targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
+
+ Assert.assertEquals(targetR.getQ0(),
+ state.getAttitude().getRotation().getQ0(),
+ 1.0e-16);
+ Assert.assertEquals(targetR.getQ1(),
+ state.getAttitude().getRotation().getQ1(),
+ 1.0e-16);
+ Assert.assertEquals(targetR.getQ2(),
+ state.getAttitude().getRotation().getQ2(),
+ 1.0e-16);
+ Assert.assertEquals(targetR.getQ3(),
+ state.getAttitude().getRotation().getQ3(),
+ 1.0e-16);
}
@Test
@@ -551,6 +575,7 @@ public class AttitudesSequenceTest {
Assert.assertEquals(0.5 * reorientationAngle,
Rotation.distance(state.getAttitude().getRotation(), targetR),
0.03 * reorientationAngle);
+
}