Search in sources :

Example 66 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class Transform method interpolate.

/**
 * Interpolate a transform from a sample set of existing transforms.
 * <p>
 * Note that even if first time derivatives (velocities and rotation rates)
 * from sample can be ignored, the interpolated instance always includes
 * interpolated derivatives. This feature can be used explicitly to
 * compute these derivatives when it would be too complex to compute them
 * from an analytical formula: just compute a few sample points from the
 * explicit formula and set the derivatives to zero in these sample points,
 * then use interpolation to add derivatives consistent with the positions
 * and rotations.
 * </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>
 * @param date interpolation date
 * @param cFilter filter for derivatives from the sample to use in interpolation
 * @param aFilter filter for derivatives from the sample to use in interpolation
 * @param sample sample points on which interpolation should be done
 * @return a new instance, interpolated at specified date
 * @exception OrekitException if the number of point is too small for interpolating
 * @since 7.0
 */
public static Transform interpolate(final AbsoluteDate date, final CartesianDerivativesFilter cFilter, final AngularDerivativesFilter aFilter, final Collection<Transform> sample) throws OrekitException {
    final List<TimeStampedPVCoordinates> datedPV = new ArrayList<TimeStampedPVCoordinates>(sample.size());
    final List<TimeStampedAngularCoordinates> datedAC = new ArrayList<TimeStampedAngularCoordinates>(sample.size());
    for (final Transform t : sample) {
        datedPV.add(new TimeStampedPVCoordinates(t.getDate(), t.getTranslation(), t.getVelocity(), t.getAcceleration()));
        datedAC.add(new TimeStampedAngularCoordinates(t.getDate(), t.getRotation(), t.getRotationRate(), t.getRotationAcceleration()));
    }
    final TimeStampedPVCoordinates interpolatedPV = TimeStampedPVCoordinates.interpolate(date, cFilter, datedPV);
    final TimeStampedAngularCoordinates interpolatedAC = TimeStampedAngularCoordinates.interpolate(date, aFilter, datedAC);
    return new Transform(date, interpolatedPV, interpolatedAC);
}
Also used : ArrayList(java.util.ArrayList) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates)

Example 67 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class OEMParserTest method testParseOemMissingOptionalData.

@Test
public void testParseOemMissingOptionalData() throws OrekitException, IOException {
    final String ex = "/ccsds/OEMExample6.txt";
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
    final OEMFile file = parser.parse(inEntry);
    Assert.assertEquals(CcsdsTimeScale.UTC, file.getEphemeridesBlocks().get(0).getMetaData().getTimeSystem());
    Assert.assertEquals("MARS GLOBAL SURVEYOR", file.getEphemeridesBlocks().get(0).getMetaData().getObjectName());
    Assert.assertEquals("1996-062A", file.getEphemeridesBlocks().get(0).getMetaData().getObjectID());
    Assert.assertEquals(1, file.getSatellites().size());
    Assert.assertEquals(true, file.getSatellites().containsKey("1996-062A"));
    Assert.assertEquals(false, file.getSatellites().containsKey("MARS GLOBAL SURVEYOR"));
    Assert.assertEquals(1, file.getSatellites().size());
    Assert.assertEquals("1996-062A", file.getSatellites().values().iterator().next().getId());
    Assert.assertEquals(new AbsoluteDate("2002-12-18T12:00:00.331", TimeScalesFactory.getUTC()), file.getEphemeridesBlocks().get(0).getStartTime());
    OemSatelliteEphemeris satellite = file.getSatellites().get("1996-062A");
    Assert.assertEquals(satellite.getId(), "1996-062A");
    Assert.assertEquals(satellite.getMu(), file.getMuUsed(), 0);
    EphemeridesBlock actualBlock = satellite.getSegments().get(0);
    Assert.assertEquals(actualBlock.getMu(), file.getMuUsed(), 0);
    FactoryManagedFrame eme2000 = FramesFactory.getEME2000();
    Frame actualFrame = actualBlock.getFrame();
    AbsoluteDate actualStart = satellite.getStart();
    Transform actualTransform = eme2000.getTransformTo(actualFrame, actualStart);
    CelestialBody mars = CelestialBodyFactory.getMars();
    TimeStampedPVCoordinates marsPV = mars.getPVCoordinates(actualStart, eme2000);
    Assert.assertEquals(actualTransform.getTranslation(), marsPV.getPosition());
    Assert.assertEquals(actualTransform.getVelocity(), marsPV.getVelocity());
    Assert.assertEquals(actualTransform.getAcceleration(), marsPV.getAcceleration());
    Assert.assertEquals(Rotation.distance(actualTransform.getRotation(), Rotation.IDENTITY), 0.0, 0.0);
    Assert.assertEquals(actualTransform.getRotationRate(), Vector3D.ZERO);
    Assert.assertEquals(actualTransform.getRotationAcceleration(), Vector3D.ZERO);
    Assert.assertEquals(actualFrame.getName(), "Mars/EME2000");
    Assert.assertEquals(actualBlock.getFrameString(), "EME2000");
    Assert.assertEquals(actualBlock.getTimeScaleString(), "UTC");
    Assert.assertEquals(actualBlock.getTimeScale(), TimeScalesFactory.getUTC());
    Assert.assertEquals(actualBlock.getAvailableDerivatives(), CartesianDerivativesFilter.USE_PV);
    Assert.assertEquals(satellite.getSegments().get(0).getStartTime(), actualStart);
    Assert.assertEquals(satellite.getSegments().get(2).getStopTime(), satellite.getStop());
    final BoundedPropagator propagator = satellite.getPropagator();
    Assert.assertEquals(propagator.getMinDate(), satellite.getStart());
    Assert.assertEquals(propagator.getMinDate(), satellite.getSegments().get(0).getStart());
    Assert.assertEquals(propagator.getMaxDate(), satellite.getStop());
    Assert.assertEquals(propagator.getMaxDate(), satellite.getSegments().get(2).getStop());
    final List<TimeStampedPVCoordinates> dataLines = new ArrayList<>();
    for (EphemeridesBlock block : file.getEphemeridesBlocks()) {
        for (TimeStampedPVCoordinates dataLine : block.getEphemeridesDataLines()) {
            if (dataLine.getDate().compareTo(satellite.getStart()) >= 0) {
                dataLines.add(dataLine);
            }
        }
    }
    final int ulps = 12;
    for (TimeStampedPVCoordinates coord : dataLines) {
        Assert.assertThat(propagator.getPVCoordinates(coord.getDate(), actualFrame), OrekitMatchers.pvCloseTo(coord, ulps));
        Assert.assertThat(propagator.propagate(coord.getDate()).getPVCoordinates(), OrekitMatchers.pvCloseTo(coord, ulps));
    }
}
Also used : Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInputStream(java.io.SequenceInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) EphemeridesBlock(org.orekit.files.ccsds.OEMFile.EphemeridesBlock) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) CelestialBody(org.orekit.bodies.CelestialBody) OemSatelliteEphemeris(org.orekit.files.ccsds.OEMFile.OemSatelliteEphemeris) Transform(org.orekit.frames.Transform) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Example 68 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class ImpulseManeuverTest method testAdditionalStateNumerical.

@Test
public void testAdditionalStateNumerical() throws OrekitException {
    final double mu = CelestialBodyFactory.getEarth().getGM();
    final double initialX = 7100e3;
    final double initialY = 0.0;
    final double initialZ = 1300e3;
    final double initialVx = 0;
    final double initialVy = 8000;
    final double initialVz = 1000;
    final Vector3D position = new Vector3D(initialX, initialY, initialZ);
    final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
    final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
    final double totalPropagationTime = 10.0;
    final double deltaX = 0.01;
    final double deltaY = 0.02;
    final double deltaZ = 0.03;
    final double isp = 300;
    final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
    final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
    final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
    double[][] tolerances = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    DormandPrince853Integrator integrator = new DormandPrince853Integrator(1.0e-3, 60, tolerances[0], tolerances[1]);
    NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setOrbitType(initialOrbit.getType());
    PartialDerivativesEquations pde = new PartialDerivativesEquations("derivatives", propagator);
    final SpacecraftState initialState = pde.setInitialJacobians(new SpacecraftState(initialOrbit, initialAttitude));
    propagator.resetInitialState(initialState);
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
    InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
    ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
    propagator.addEventDetector(burnAtEpoch);
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
    Assert.assertEquals(1, finalState.getAdditionalStates().size());
    Assert.assertEquals(36, finalState.getAdditionalState("derivatives").length);
    double[][] stateTransitionMatrix = new double[6][6];
    pde.getMapper().getStateJacobian(finalState, stateTransitionMatrix);
    for (int i = 0; i < 6; ++i) {
        for (int j = 0; j < 6; ++j) {
            double sIJ = stateTransitionMatrix[i][j];
            if (j == i) {
                // dPi/dPj and dVi/dVj are roughly 1 for small propagation times
                Assert.assertEquals(1.0, sIJ, 2.0e-4);
            } else if (j == i + 3) {
                // dVi/dPi is roughly the propagation time for small propagation times
                Assert.assertEquals(totalPropagationTime, sIJ, 4.0e-5 * totalPropagationTime);
            } else {
                // other derivatives are almost zero for small propagation times
                Assert.assertEquals(0, sIJ, 1.0e-4);
            }
        }
    }
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Attitude(org.orekit.attitudes.Attitude) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) PartialDerivativesEquations(org.orekit.propagation.numerical.PartialDerivativesEquations) InertialProvider(org.orekit.attitudes.InertialProvider) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 69 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class ImpulseManeuverTest method testInertialManeuver.

@Test
public void testInertialManeuver() throws OrekitException {
    final double mu = CelestialBodyFactory.getEarth().getGM();
    final double initialX = 7100e3;
    final double initialY = 0.0;
    final double initialZ = 1300e3;
    final double initialVx = 0;
    final double initialVy = 8000;
    final double initialVz = 1000;
    final Vector3D position = new Vector3D(initialX, initialY, initialZ);
    final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
    final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
    final TimeStampedPVCoordinates state = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(state, FramesFactory.getEME2000(), mu);
    final double totalPropagationTime = 0.00001;
    final double driftTimeInSec = totalPropagationTime / 2.0;
    final double deltaX = 0.01;
    final double deltaY = 0.02;
    final double deltaZ = 0.03;
    final double isp = 300;
    final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC));
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(driftTimeInSec));
    InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
    ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(driftTimeInSec / 4);
    propagator.addEventDetector(burnAtEpoch);
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
    final double finalVxExpected = initialVx + deltaX;
    final double finalVyExpected = initialVy + deltaY;
    final double finalVzExpected = initialVz + deltaZ;
    final double maneuverTolerance = 1e-4;
    final Vector3D finalVelocity = finalState.getPVCoordinates().getVelocity();
    Assert.assertEquals(finalVxExpected, finalVelocity.getX(), maneuverTolerance);
    Assert.assertEquals(finalVyExpected, finalVelocity.getY(), maneuverTolerance);
    Assert.assertEquals(finalVzExpected, finalVelocity.getZ(), maneuverTolerance);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InertialProvider(org.orekit.attitudes.InertialProvider) LofOffset(org.orekit.attitudes.LofOffset) Test(org.junit.Test)

Example 70 with TimeStampedPVCoordinates

use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.

the class ImpulseManeuverTest method testAdditionalStateKeplerian.

@Test
public void testAdditionalStateKeplerian() throws OrekitException {
    final double mu = CelestialBodyFactory.getEarth().getGM();
    final double initialX = 7100e3;
    final double initialY = 0.0;
    final double initialZ = 1300e3;
    final double initialVx = 0;
    final double initialVy = 8000;
    final double initialVz = 1000;
    final Vector3D position = new Vector3D(initialX, initialY, initialZ);
    final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
    final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(epoch, position, velocity, Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), mu);
    final double totalPropagationTime = 10;
    final double deltaX = 0.01;
    final double deltaY = 0.02;
    final double deltaZ = 0.03;
    final double isp = 300;
    final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);
    final AttitudeProvider attitudeProvider = new LofOffset(initialOrbit.getFrame(), LOFType.VNC);
    final Attitude initialAttitude = attitudeProvider.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame());
    final SpacecraftState initialState = new SpacecraftState(initialOrbit, initialAttitude);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    propagator.resetInitialState(initialState.addAdditionalState("testOnly", -1.0));
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(0.5 * totalPropagationTime));
    InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, RotationConvention.VECTOR_OPERATOR, 0, 0, 0));
    ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector, attitudeOverride, deltaV, isp).withThreshold(1.0e-3);
    propagator.addEventDetector(burnAtEpoch);
    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));
    Assert.assertEquals(1, finalState.getAdditionalStates().size());
    Assert.assertEquals(-1.0, finalState.getAdditionalState("testOnly")[0], 1.0e-15);
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Attitude(org.orekit.attitudes.Attitude) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InertialProvider(org.orekit.attitudes.InertialProvider) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Aggregations

TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)103 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)64 Test (org.junit.Test)50 AbsoluteDate (org.orekit.time.AbsoluteDate)48 SpacecraftState (org.orekit.propagation.SpacecraftState)36 Frame (org.orekit.frames.Frame)27 ArrayList (java.util.ArrayList)24 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)23 Transform (org.orekit.frames.Transform)22 CartesianOrbit (org.orekit.orbits.CartesianOrbit)20 Orbit (org.orekit.orbits.Orbit)19 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)17 PVCoordinates (org.orekit.utils.PVCoordinates)17 OrekitException (org.orekit.errors.OrekitException)15 BoundedPropagator (org.orekit.propagation.BoundedPropagator)12 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)11 CircularOrbit (org.orekit.orbits.CircularOrbit)11 Propagator (org.orekit.propagation.Propagator)11 FieldTransform (org.orekit.frames.FieldTransform)10