Search in sources :

Example 1 with FactoryManagedFrame

use of org.orekit.frames.FactoryManagedFrame 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 2 with FactoryManagedFrame

use of org.orekit.frames.FactoryManagedFrame in project Orekit by CS-SI.

the class OrekitStepHandlerTest method testForwardBackwardStep.

@Test
public void testForwardBackwardStep() throws OrekitException, InterruptedException, ExecutionException {
    final AbsoluteDate initialDate = new AbsoluteDate(2014, 01, 01, 00, 00, 00.000, TimeScalesFactory.getUTC());
    final double mu = CelestialBodyFactory.getEarth().getGM();
    FactoryManagedFrame inertialFrame = FramesFactory.getEME2000();
    // seconds
    final double propagationTime = 7200.0;
    // seconds
    final double fixedStepSize = 3600;
    // meters
    final double semimajorAxis = 8000e3;
    // unitless
    final double eccentricity = 0.001;
    final double inclination = FastMath.toRadians(15.0);
    final double argPerigee = FastMath.toRadians(10.0);
    final double raan = FastMath.toRadians(45.0);
    final double trueAnomaly = FastMath.toRadians(10.0);
    KeplerianOrbit initialOrbit = new KeplerianOrbit(semimajorAxis, eccentricity, inclination, argPerigee, raan, trueAnomaly, PositionAngle.TRUE, inertialFrame, initialDate, mu);
    final Propagator kepler = new KeplerianPropagator(initialOrbit);
    kepler.setMasterMode(fixedStepSize, new OrekitFixedStepHandler() {

        @Override
        public void handleStep(SpacecraftState currentState, boolean isLast) {
        }
    });
    kepler.propagate(initialDate.shiftedBy(propagationTime));
    final double stepSizeInSeconds = 120;
    final long longestWaitTimeMS = 20;
    ExecutorService service = Executors.newSingleThreadExecutor();
    for (double elapsedTime = 0; elapsedTime <= propagationTime; elapsedTime += stepSizeInSeconds) {
        final double dt = elapsedTime;
        Future<SpacecraftState> stateFuture = service.submit(new Callable<SpacecraftState>() {

            public SpacecraftState call() throws OrekitException {
                return kepler.propagate(initialDate.shiftedBy(dt));
            }
        });
        Thread.sleep(longestWaitTimeMS);
        assertTrue(stateFuture.isDone());
        SpacecraftState finalState = stateFuture.get();
        assertNotNull(finalState);
    }
}
Also used : FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ExecutorService(java.util.concurrent.ExecutorService) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FactoryManagedFrame (org.orekit.frames.FactoryManagedFrame)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 SequenceInputStream (java.io.SequenceInputStream)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 CelestialBody (org.orekit.bodies.CelestialBody)1 OrekitException (org.orekit.errors.OrekitException)1 EphemeridesBlock (org.orekit.files.ccsds.OEMFile.EphemeridesBlock)1 OemSatelliteEphemeris (org.orekit.files.ccsds.OEMFile.OemSatelliteEphemeris)1 Frame (org.orekit.frames.Frame)1 Transform (org.orekit.frames.Transform)1 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)1 BoundedPropagator (org.orekit.propagation.BoundedPropagator)1 Propagator (org.orekit.propagation.Propagator)1 SpacecraftState (org.orekit.propagation.SpacecraftState)1 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)1 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)1