Commit 0ea18459 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed continuous maneuver handling in backward propagation.

Fixes issue #236
parent 1a5267e9
......@@ -34,12 +34,12 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** This class implements a simple maneuver with constant thrust.
* <p>The maneuver is defined by a direction in satelliteframe.
* <p>The maneuver is defined by a direction in satellite frame.
* The current attitude of the spacecraft, defined by the current
* spacecraft state, will be used to compute the thrust direction in
* inertial frame. A typical case for tangential maneuvers is to use a
* {@link org.orekit.attitudes.LofOffset LOF aligned} attitude provider for state propagation and a
* velocity increment along the +X satellite axis.</p>
* {@link org.orekit.attitudes.LofOffset LOF aligned} attitude provider
* for state propagation and a velocity increment along the +X satellite axis.</p>
* @author Fabien Maussion
* @author V&eacute;ronique Pommier-Maurussane
* @author Luc Maisonobe
......@@ -151,9 +151,8 @@ public class ConstantThrustManeuver extends AbstractParameterizable implements F
// constant (and null) acceleration when not firing
final int parameters = mass.getFreeParameters();
final int order = mass.getOrder();
return new FieldVector3D<DerivativeStructure>(new DerivativeStructure(parameters, order, 0.0),
new DerivativeStructure(parameters, order, 0.0),
new DerivativeStructure(parameters, order, 0.0));
final DerivativeStructure zero = new DerivativeStructure(parameters, order, 0.0);
return new FieldVector3D<DerivativeStructure>(zero, zero, zero);
}
}
......@@ -223,8 +222,15 @@ public class ConstantThrustManeuver extends AbstractParameterizable implements F
public EventHandler.Action eventOccurred(final SpacecraftState s,
final DateDetector detector,
final boolean increasing) {
// start the maneuver
firing = true;
if (detector.isForward()) {
// we are in the forward direction,
// starting now, the maneuver is ON as it has just started
firing = true;
} else {
// we are in the backward direction,
// starting now, the maneuver is OFF as it has not started yet
firing = false;
}
return EventHandler.Action.RESET_DERIVATIVES;
}
......@@ -244,7 +250,15 @@ public class ConstantThrustManeuver extends AbstractParameterizable implements F
final DateDetector detector,
final boolean increasing) {
// stop the maneuver
firing = false;
if (detector.isForward()) {
// we are in the forward direction,
// starting now, the maneuver is OFF as it has just ended
firing = false;
} else {
// we are in the backward direction,
// starting now, the maneuver is ON as it has not ended yet
firing = true;
}
return EventHandler.Action.RESET_DERIVATIVES;
}
......
......@@ -51,6 +51,9 @@ public abstract class AbstractDetector<T extends EventDetector> implements Event
/** Default handler for event overrides. */
private final EventHandler<? super T> handler;
/** Propagation direction. */
private boolean forward;
/** Build a new instance.
* @param maxCheck maximum checking interval (s)
* @param threshold convergence threshold (s)
......@@ -63,11 +66,12 @@ public abstract class AbstractDetector<T extends EventDetector> implements Event
this.threshold = threshold;
this.maxIter = maxIter;
this.handler = handler;
this.forward = true;
}
/** {@inheritDoc} */
public void init(final SpacecraftState s0, final AbsoluteDate t) {
// do nothing by default
forward = t.durationFrom(s0.getDate()) >= 0.0;
}
/** {@inheritDoc} */
......@@ -172,4 +176,11 @@ public abstract class AbstractDetector<T extends EventDetector> implements Event
protected abstract T create(final double newMaxCheck, final double newThreshold,
final int newMaxIter, final EventHandler<? super T> newHandler);
/** Check if the current propagation is forward or backward.
* @return true if the current propagation is forward
*/
public boolean isForward() {
return forward;
}
}
......@@ -20,6 +20,13 @@
<title>Orekit Changes</title>
</properties>
<body>
<release version="7.2" date="TBC"
description="">
<action dev="luc" type="fix">
Fixed wrong continuous maneuver handling in backward propagation.
Fixes issue #236
</action>
</release>
<release version="7.1" date="2016-02-07"
description="Version 7.1 is a minor release of Orekit. It introduces several new
features and bug fixes. The most important features introduced in version 7.1
......
......@@ -34,6 +34,7 @@ import org.orekit.frames.FramesFactory;
import org.orekit.orbits.CircularOrbit;
import org.orekit.orbits.KeplerianOrbit;
import org.orekit.orbits.Orbit;
import org.orekit.orbits.OrbitType;
import org.orekit.orbits.PositionAngle;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.events.EventDetector;
......@@ -149,6 +150,63 @@ public class ConstantThrustManeuverTest {
}
@Test
public void testForwardAndBackward() throws OrekitException {
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01),
new TimeComponents(23, 30, 00.000),
TimeScalesFactory.getUTC());
final Orbit orbit =
new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE,
FramesFactory.getEME2000(), initDate, mu);
final SpacecraftState initialState =
new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02),
new TimeComponents(04, 15, 34.080),
TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuver =
new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
AdaptiveStepsizeIntegrator integrator1 =
new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator1.setInitialStepSize(60);
final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
propagator1.setInitialState(initialState);
propagator1.setAttitudeProvider(law);
propagator1.addForceModel(maneuver);
final SpacecraftState finalState = propagator1.propagate(fireDate.shiftedBy(3800));
AdaptiveStepsizeIntegrator integrator2 =
new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator2.setInitialStepSize(60);
final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
propagator2.setInitialState(finalState);
propagator2.setAttitudeProvider(law);
propagator2.addForceModel(maneuver);
final SpacecraftState recoveredState = propagator2.propagate(orbit.getDate());
final Vector3D refPosition = initialState.getPVCoordinates().getPosition();
final Vector3D recoveredPosition = recoveredState.getPVCoordinates().getPosition();
Assert.assertEquals(0.0, Vector3D.distance(refPosition, recoveredPosition), 30.0);
Assert.assertEquals(initialState.getMass(), recoveredState.getMass(), 1.5e-10);
}
@Before
public void setUp() {
Utils.setDataRoot("regular-data");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment