use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class NadirPointingTest method testSpin.
@Test
public void testSpin() throws OrekitException {
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create earth center pointing attitude provider
NadirPointing law = new NadirPointing(FramesFactory.getEME2000(), earthShape);
// Satellite on any position
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
Propagator propagator = new KeplerianPropagator(orbit, law, mu, 2500.0);
double h = 0.1;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus, 5.3e-9 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus, 8.1e-9 * evolutionAnglePlus);
Vector3D spin0 = s0.getAttitude().getSpin();
Rotation rM = sMinus.getAttitude().getRotation();
Rotation rP = sPlus.getAttitude().getRotation();
Vector3D reference = AngularCoordinates.estimateRate(rM, rP, 2 * h);
Assert.assertTrue(Rotation.distance(rM, rP) > 2.0e-4);
Assert.assertEquals(0.0, spin0.subtract(reference).getNorm(), 2.0e-6);
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class InertialAttitudeTest method testSpin.
@Test
public void testSpin() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2, RotationConvention.VECTOR_OPERATOR));
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
Propagator propagator = new KeplerianPropagator(orbit, law);
double h = 100.0;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
// compute spin axis using finite differences
Rotation rMinus = sMinus.getAttitude().getRotation();
Rotation rPlus = sPlus.getAttitude().getRotation();
Rotation dr = rPlus.compose(rMinus.revert(), RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0, dr.getAngle(), 1.0e-10);
Vector3D spin0 = s0.getAttitude().getSpin();
Assert.assertEquals(0, spin0.getNorm(), 1.0e-10);
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class InertialAttitudeTest method testCompensateMomentum.
@Test
public void testCompensateMomentum() throws OrekitException {
InertialProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2, RotationConvention.VECTOR_OPERATOR));
KeplerianPropagator propagator = new KeplerianPropagator(orbit0, law);
Attitude initial = propagator.propagate(t0).getAttitude();
for (double t = 0; t < 10000.0; t += 100) {
Attitude attitude = propagator.propagate(t0.shiftedBy(t)).getAttitude();
Rotation evolution = attitude.getRotation().compose(initial.getRotation().revert(), RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0, evolution.getAngle(), 1.0e-10);
Assert.assertEquals(FramesFactory.getEME2000(), attitude.getReferenceFrame());
}
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class SpinStabilizedTest method testSpin.
@Test
public void testSpin() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
double rate = 2.0 * FastMath.PI / (12 * 60);
AttitudeProvider law = new SpinStabilized(new InertialProvider(Rotation.IDENTITY), date, Vector3D.PLUS_K, rate);
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
Propagator propagator = new KeplerianPropagator(orbit, law);
double h = 10.0;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
Vector3D spin0 = s0.getAttitude().getSpin();
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertTrue(errorAngleMinus <= 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertTrue(errorAnglePlus <= 1.0e-6 * evolutionAnglePlus);
// compute spin axis using finite differences
Rotation rM = sMinus.getAttitude().getRotation();
Rotation rP = sPlus.getAttitude().getRotation();
Vector3D reference = AngularCoordinates.estimateRate(rM, rP, 2 * h);
Assert.assertEquals(2 * FastMath.PI / reference.getNorm(), 2 * FastMath.PI / spin0.getNorm(), 0.05);
Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(reference, spin0)), 1.0e-10);
Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(Vector3D.PLUS_K, spin0)), 1.0e-10);
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class TabulatedLofOffsetTest method testSerialization.
@Test
public void testSerialization() throws OrekitException, IOException, ClassNotFoundException {
// create a sample from Yaw compensation law
final LOFType type = LOFType.VNC;
final List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
final AttitudeProvider yawCompensLaw = new YawCompensation(orbit.getFrame(), new NadirPointing(orbit.getFrame(), earth));
final Propagator originalPropagator = new KeplerianPropagator(orbit);
originalPropagator.setAttitudeProvider(yawCompensLaw);
originalPropagator.setMasterMode(10.0, new OrekitFixedStepHandler() {
public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
Rotation offsetAtt = currentState.getAttitude().getRotation();
LofOffset aligned = new LofOffset(currentState.getFrame(), type);
Rotation alignedAtt = aligned.getAttitude(currentState.getOrbit(), currentState.getDate(), currentState.getFrame()).getRotation();
Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
sample.add(new TimeStampedAngularCoordinates(currentState.getDate(), offsetProper, Vector3D.ZERO, Vector3D.ZERO));
}
});
originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
originalPropagator.setSlaveMode();
// use the sample and generate an ephemeris
final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
rebuildingPropagator.setAttitudeProvider(tabulated);
rebuildingPropagator.setEphemerisMode();
rebuildingPropagator.propagate(orbit.getDate().shiftedBy(5));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(rebuildingPropagator.getGeneratedEphemeris());
// even despite we propagated only 5 seconds, the attitude sample is huge
Assert.assertTrue(bos.size() > 17000);
Assert.assertTrue(bos.size() < 18000);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
TabulatedLofOffset deserialized = (TabulatedLofOffset) ((BoundedPropagator) ois.readObject()).getAttitudeProvider();
Assert.assertEquals(sample.size(), deserialized.getTable().size());
}
Aggregations