use of org.orekit.frames.LOFType in project Orekit by CS-SI.
the class LofOffsetPointingTest method testTypesField.
@Test
public void testTypesField() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
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);
for (final LOFType type : LOFType.values()) {
RotationOrder order = RotationOrder.ZXY;
double alpha1 = 0.123;
double alpha2 = 0.456;
double alpha3 = 0.789;
LofOffset law = new LofOffset(orbit.getFrame(), type, order, alpha1, alpha2, alpha3);
final Vector3D dir;
switch(type) {
case TNW:
dir = Vector3D.PLUS_J;
break;
case QSW:
case LVLH:
dir = Vector3D.MINUS_I;
break;
case VVLH:
dir = Vector3D.PLUS_K;
break;
default:
// VNC
dir = Vector3D.MINUS_K;
}
LofOffsetPointing lop = new LofOffsetPointing(orbit.getFrame(), earthSpheric, law, dir);
checkField(Decimal64Field.getInstance(), lop, orbit, date, orbit.getFrame());
}
}
use of org.orekit.frames.LOFType in project Orekit by CS-SI.
the class LofOffsetTest method testTypesField.
@Test
public void testTypesField() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
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);
for (final LOFType type : LOFType.values()) {
RotationOrder order = RotationOrder.ZXY;
double alpha1 = 0.123;
double alpha2 = 0.456;
double alpha3 = 0.789;
LofOffset law = new LofOffset(orbit.getFrame(), type, order, alpha1, alpha2, alpha3);
checkField(Decimal64Field.getInstance(), law, orbit, date, orbit.getFrame());
}
}
use of org.orekit.frames.LOFType 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());
}
use of org.orekit.frames.LOFType in project Orekit by CS-SI.
the class TabulatedLofOffsetTest method testYawCompensation.
@Test
public void testYawCompensation() throws OrekitException {
// 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(1.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 compare it to original
final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
rebuildingPropagator.setAttitudeProvider(tabulated);
rebuildingPropagator.setMasterMode(0.3, new OrekitFixedStepHandler() {
public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
final SpacecraftState rebuilt = originalPropagator.propagate(currentState.getDate());
final Rotation r1 = currentState.getAttitude().getRotation();
final Rotation r2 = rebuilt.getAttitude().getRotation();
Assert.assertEquals(0.0, Rotation.distance(r1, r2), 7.0e-6);
checkField(Decimal64Field.getInstance(), tabulated, currentState.getOrbit(), currentState.getDate(), currentState.getFrame());
}
});
rebuildingPropagator.propagate(orbit.getDate().shiftedBy(50), orbit.getDate().shiftedBy(1950));
}
use of org.orekit.frames.LOFType in project Orekit by CS-SI.
the class TabulatedLofOffsetTest method testConstantOffset.
@Test
public void testConstantOffset() throws OrekitException {
RandomGenerator random = new Well19937a(0x1199d4bb8f53d2b6l);
for (LOFType type : LOFType.values()) {
for (int i = 0; i < 100; ++i) {
double a1 = random.nextDouble() * MathUtils.TWO_PI;
double a2 = random.nextDouble() * MathUtils.TWO_PI;
double a3 = random.nextDouble() * MathUtils.TWO_PI;
LofOffset law = new LofOffset(orbit.getFrame(), type, RotationOrder.XYZ, a1, a2, a3);
Rotation offsetAtt = law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
LofOffset aligned = new LofOffset(orbit.getFrame(), type);
Rotation alignedAtt = aligned.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
TabulatedLofOffset tabulated = new TabulatedLofOffset(orbit.getFrame(), type, Arrays.asList(new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(-10), offsetProper, Vector3D.ZERO, Vector3D.ZERO), new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(0), offsetProper, Vector3D.ZERO, Vector3D.ZERO), new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(+10), offsetProper, Vector3D.ZERO, Vector3D.ZERO)), 2, AngularDerivativesFilter.USE_R);
Rotation rebuilt = tabulated.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
Assert.assertEquals(0.0, Rotation.distance(offsetAtt, rebuilt), 1.2e-15);
}
}
}
Aggregations