use of org.orekit.utils.TimeStampedAngularCoordinates in project Orekit by CS-SI.
the class TabulatedLofOffset method getAttitude.
/**
* {@inheritDoc}
*/
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// get attitudes sample on which interpolation will be performed
final List<TimeStampedAngularCoordinates> sample = table.getNeighbors(date).collect(Collectors.toList());
// interpolate
final TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(date, filter, sample);
// construction of the local orbital frame, using PV from inertial frame
final PVCoordinates pv = pvProv.getPVCoordinates(date, inertialFrame);
final Transform inertialToLof = type.transformFromInertial(date, pv);
// take into account the specified start frame (which may not be an inertial one)
final Transform frameToInertial = frame.getTransformTo(inertialFrame, date);
final Transform frameToLof = new Transform(date, frameToInertial, inertialToLof);
// compose with interpolated rotation
return new Attitude(date, frame, interpolated.addOffset(frameToLof.getAngular()));
}
use of org.orekit.utils.TimeStampedAngularCoordinates in project Orekit by CS-SI.
the class Attitude method interpolate.
/**
* {@inheritDoc}
* <p>
* The interpolated instance is created by polynomial Hermite interpolation
* on Rodrigues vector ensuring rotation rate remains the exact derivative of rotation.
* </p>
* <p>
* As this implementation of interpolation is polynomial, it should be used only
* with small samples (about 10-20 points) in order to avoid <a
* href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's phenomenon</a>
* and numerical problems (including NaN appearing).
* </p>
* @exception OrekitException if the number of point is too small for interpolating
*/
public Attitude interpolate(final AbsoluteDate interpolationDate, final Stream<Attitude> sample) throws OrekitException {
final List<TimeStampedAngularCoordinates> datedPV = sample.map(attitude -> attitude.orientation).collect(Collectors.toList());
final TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(interpolationDate, AngularDerivativesFilter.USE_RR, datedPV);
return new Attitude(referenceFrame, interpolated);
}
use of org.orekit.utils.TimeStampedAngularCoordinates 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.utils.TimeStampedAngularCoordinates 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.utils.TimeStampedAngularCoordinates in project Orekit by CS-SI.
the class TabulatedProviderTest method testWithRate.
@Test
public void testWithRate() throws OrekitException {
double samplingRate = 10.0;
double checkingRate = 1.0;
int n = 8;
AttitudeProvider referenceProvider = new NadirPointing(circOrbit.getFrame(), earthShape);
List<TimeStampedAngularCoordinates> sample = createSample(samplingRate, referenceProvider);
final double margin = samplingRate * n / 2;
final AbsoluteDate start = sample.get(0).getDate().shiftedBy(margin);
final AbsoluteDate end = sample.get(sample.size() - 1).getDate().shiftedBy(-margin);
TabulatedProvider provider = new TabulatedProvider(circOrbit.getFrame(), sample, n, AngularDerivativesFilter.USE_RR);
Assert.assertEquals(0.0, checkError(start, end, checkingRate, referenceProvider, provider), 1.3e-11);
}
Aggregations