Search in sources :

Example 1 with TimeStampedAngularCoordinates

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()));
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Transform(org.orekit.frames.Transform) FieldTransform(org.orekit.frames.FieldTransform) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates)

Example 2 with TimeStampedAngularCoordinates

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);
}
Also used : AngularCoordinates(org.orekit.utils.AngularCoordinates) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Frame(org.orekit.frames.Frame) TimeInterpolable(org.orekit.time.TimeInterpolable) AngularDerivativesFilter(org.orekit.utils.AngularDerivativesFilter) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) RotationConvention(org.hipparchus.geometry.euclidean.threed.RotationConvention) List(java.util.List) Stream(java.util.stream.Stream) OrekitException(org.orekit.errors.OrekitException) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Transform(org.orekit.frames.Transform) TimeShiftable(org.orekit.time.TimeShiftable) AbsoluteDate(org.orekit.time.AbsoluteDate) TimeStamped(org.orekit.time.TimeStamped) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates)

Example 3 with TimeStampedAngularCoordinates

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());
}
Also used : ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) ByteArrayInputStream(java.io.ByteArrayInputStream) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 4 with TimeStampedAngularCoordinates

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));
}
Also used : ArrayList(java.util.ArrayList) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Test(org.junit.Test)

Example 5 with TimeStampedAngularCoordinates

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);
}
Also used : TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

TimeStampedAngularCoordinates (org.orekit.utils.TimeStampedAngularCoordinates)14 Test (org.junit.Test)7 AbsoluteDate (org.orekit.time.AbsoluteDate)5 ArrayList (java.util.ArrayList)4 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)4 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)4 OrekitException (org.orekit.errors.OrekitException)3 LOFType (org.orekit.frames.LOFType)3 Transform (org.orekit.frames.Transform)3 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)3 SpacecraftState (org.orekit.propagation.SpacecraftState)3 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)3 OrekitFixedStepHandler (org.orekit.propagation.sampling.OrekitFixedStepHandler)3 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2