Search in sources :

Example 36 with KeplerianPropagator

use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.

the class FieldOfViewTest method testNadirHexagonalFootprint.

@Test
public void testNadirHexagonalFootprint() throws OrekitException {
    Utils.setDataRoot("regular-data");
    FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(3.0), 6, 0.0);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
    Propagator propagator = new KeplerianPropagator(orbit);
    propagator.setAttitudeProvider(new NadirPointing(orbit.getFrame(), earth));
    SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
    Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
    Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
    List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(0.1));
    Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
    Assert.assertEquals(1, footprint.size());
    List<GeodeticPoint> loop = footprint.get(0);
    Assert.assertEquals(210, loop.size());
    double minEl = Double.POSITIVE_INFINITY;
    double maxEl = 0;
    double minDist = Double.POSITIVE_INFINITY;
    double maxDist = 0;
    for (int i = 0; i < loop.size(); ++i) {
        Assert.assertEquals(0.0, loop.get(i).getAltitude(), 1.0e-15);
        TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
        final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
        minEl = FastMath.min(minEl, elevation);
        maxEl = FastMath.max(maxEl, elevation);
        final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
        minDist = FastMath.min(minDist, dist);
        maxDist = FastMath.max(maxDist, dist);
    }
    Assert.assertEquals(84.6497, FastMath.toDegrees(minEl), 0.001);
    Assert.assertEquals(85.3729, FastMath.toDegrees(maxEl), 0.001);
    Assert.assertEquals(181052.2, minDist, 1.0);
    Assert.assertEquals(209092.8, maxDist, 1.0);
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) PVCoordinates(org.orekit.utils.PVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) List(java.util.List) Transform(org.orekit.frames.Transform) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 37 with KeplerianPropagator

use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.

the class FieldOfViewTest method testFOVLargerThanEarth.

@Test
public void testFOVLargerThanEarth() throws OrekitException {
    Utils.setDataRoot("regular-data");
    FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(45.0), 6, 0.0);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
    Propagator propagator = new KeplerianPropagator(orbit);
    propagator.setAttitudeProvider(new NadirPointing(orbit.getFrame(), earth));
    SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
    Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
    Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
    List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(1.0));
    Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
    Assert.assertEquals(1, footprint.size());
    List<GeodeticPoint> loop = footprint.get(0);
    Assert.assertEquals(234, loop.size());
    double minEl = Double.POSITIVE_INFINITY;
    double maxEl = 0;
    double minDist = Double.POSITIVE_INFINITY;
    double maxDist = 0;
    for (int i = 0; i < loop.size(); ++i) {
        Assert.assertEquals(0.0, loop.get(i).getAltitude(), 3.0e-7);
        TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
        final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
        minEl = FastMath.min(minEl, elevation);
        maxEl = FastMath.max(maxEl, elevation);
        final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
        minDist = FastMath.min(minDist, dist);
        maxDist = FastMath.max(maxDist, dist);
    }
    Assert.assertEquals(0.0, FastMath.toDegrees(minEl), 2.0e-12);
    Assert.assertEquals(0.0, FastMath.toDegrees(maxEl), 1.7e-12);
    Assert.assertEquals(5323036.6, minDist, 1.0);
    Assert.assertEquals(5347029.8, maxDist, 1.0);
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) PVCoordinates(org.orekit.utils.PVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) List(java.util.List) Transform(org.orekit.frames.Transform) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 38 with KeplerianPropagator

use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.

the class GroundFieldOfViewDetectorTest method testCaseSimilarToElevationDetector.

/**
 * Check FoV detector is similar to {@link ElevationDetector} when using
 * zenith pointing.
 *
 * @throws OrekitException on error.
 */
@Test
public void testCaseSimilarToElevationDetector() throws OrekitException {
    // setup
    double pi = FastMath.PI;
    // arbitrary date
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    AbsoluteDate endDate = date.shiftedBy(Constants.JULIAN_DAY);
    Frame eci = FramesFactory.getGCRF();
    Frame ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, ecef);
    GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(39), FastMath.toRadians(77), 0);
    TopocentricFrame topo = new TopocentricFrame(earth, gp, "topo");
    // iss like orbit
    KeplerianOrbit orbit = new KeplerianOrbit(6378137 + 400e3, 0, FastMath.toRadians(51.65), 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EGM96_EARTH_MU);
    Propagator prop = new KeplerianPropagator(orbit);
    // compute expected result
    ElevationDetector elevationDetector = new ElevationDetector(topo).withConstantElevation(pi / 6).withMaxCheck(5.0);
    EventsLogger logger = new EventsLogger();
    prop.addEventDetector(logger.monitorDetector(elevationDetector));
    prop.propagate(endDate);
    List<LoggedEvent> expected = logger.getLoggedEvents();
    // action
    // construct similar FoV based detector
    // half width of 60 deg pointed along +Z in antenna frame
    // not a perfect small circle b/c FoV makes a polygon with great circles
    FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, pi / 3, 16, 0);
    // simple case for fixed pointing to be similar to elevation detector.
    // could define new frame with varying rotation for slewing antenna.
    GroundFieldOfViewDetector fovDetector = new GroundFieldOfViewDetector(topo, fov).withMaxCheck(5.0);
    Assert.assertSame(topo, fovDetector.getFrame());
    Assert.assertSame(fov, fovDetector.getFieldOfView());
    logger = new EventsLogger();
    prop = new KeplerianPropagator(orbit);
    prop.addEventDetector(logger.monitorDetector(fovDetector));
    prop.propagate(endDate);
    List<LoggedEvent> actual = logger.getLoggedEvents();
    // verify
    Assert.assertEquals(2, expected.size());
    Assert.assertEquals(2, actual.size());
    for (int i = 0; i < 2; i++) {
        AbsoluteDate expectedDate = expected.get(i).getState().getDate();
        AbsoluteDate actualDate = actual.get(i).getState().getDate();
        // same event times to within 1s.
        Assert.assertEquals(expectedDate.durationFrom(actualDate), 0.0, 1.0);
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) GroundFieldOfViewDetector(org.orekit.propagation.events.GroundFieldOfViewDetector) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ElevationDetector(org.orekit.propagation.events.ElevationDetector) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) EventsLogger(org.orekit.propagation.events.EventsLogger) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldOfView(org.orekit.propagation.events.FieldOfView) Test(org.junit.Test)

Example 39 with KeplerianPropagator

use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.

the class EventEnablingPredicateFilterTest method testExceedHistoryForward.

@Test
public void testExceedHistoryForward() throws OrekitException, IOException {
    final double period = 900.0;
    // the raw detector should trigger one event at each 900s period
    final DateDetector raw = new DateDetector(orbit.getDate().shiftedBy(-0.5 * period)).withMaxCheck(period / 3).withHandler(new ContinueOnEvent<DateDetector>());
    for (int i = 0; i < 300; ++i) {
        raw.addEventDate(orbit.getDate().shiftedBy((i + 0.5) * period));
    }
    // in fact, we will filter out half of these events, so we get only one event every 2 periods
    final EventEnablingPredicateFilter<DateDetector> filtered = new EventEnablingPredicateFilter<DateDetector>(raw, new EnablingPredicate<DateDetector>() {

        public boolean eventIsEnabled(SpacecraftState state, DateDetector eventDetector, double g) {
            double nbPeriod = state.getDate().durationFrom(orbit.getDate()) / period;
            return ((int) FastMath.floor(nbPeriod)) % 2 == 1;
        }
    });
    Propagator propagator = new KeplerianPropagator(orbit);
    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(filtered));
    propagator.propagate(orbit.getDate().shiftedBy(301 * period));
    List<LoggedEvent> events = logger.getLoggedEvents();
    // 300 periods, 150 events as half of them are filtered out
    Assert.assertEquals(150, events.size());
    // as we have encountered a lot of enabling status changes, we exceeded the internal history
    // if we try to display again the filtered g function for dates far in the past,
    // we will not see the zero crossings anymore, they have been lost
    propagator.clearEventsDetectors();
    for (double dt = 5000.0; dt < 10000.0; dt += 3.0) {
        double filteredG = filtered.g(propagator.propagate(orbit.getDate().shiftedBy(dt)));
        Assert.assertTrue(filteredG < 0.0);
    }
    // that are still inside the history, we still see the zero crossings
    for (double dt = 195400.0; dt < 196200.0; dt += 3.0) {
        double filteredG = filtered.g(propagator.propagate(orbit.getDate().shiftedBy(dt)));
        if (dt < 195750) {
            Assert.assertTrue(filteredG > 0.0);
        } else {
            Assert.assertTrue(filteredG < 0.0);
        }
    }
}
Also used : LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Test(org.junit.Test)

Example 40 with KeplerianPropagator

use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.

the class EventEnablingPredicateFilterTest method testResetState.

@Test
public void testResetState() throws OrekitException {
    final List<AbsoluteDate> reset = new ArrayList<AbsoluteDate>();
    DateDetector raw = new DateDetector(orbit.getDate().shiftedBy(3600.0)).withMaxCheck(1000.0).withHandler(new EventHandler<DateDetector>() {

        public SpacecraftState resetState(DateDetector detector, SpacecraftState oldState) {
            reset.add(oldState.getDate());
            return oldState;
        }

        public Action eventOccurred(SpacecraftState s, DateDetector detector, boolean increasing) {
            return Action.RESET_STATE;
        }
    });
    for (int i = 2; i < 10; ++i) {
        raw.addEventDate(orbit.getDate().shiftedBy(i * 3600.0));
    }
    EventEnablingPredicateFilter<DateDetector> filtered = new EventEnablingPredicateFilter<DateDetector>(raw, new EnablingPredicate<DateDetector>() {

        public boolean eventIsEnabled(SpacecraftState state, DateDetector eventDetector, double g) {
            return state.getDate().durationFrom(orbit.getDate()) > 20000.0;
        }
    });
    Propagator propagator = new KeplerianPropagator(orbit);
    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(filtered));
    propagator.propagate(orbit.getDate().shiftedBy(Constants.JULIAN_DAY));
    List<LoggedEvent> events = logger.getLoggedEvents();
    Assert.assertEquals(4, events.size());
    Assert.assertEquals(6 * 3600, events.get(0).getState().getDate().durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(7 * 3600, events.get(1).getState().getDate().durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(8 * 3600, events.get(2).getState().getDate().durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(9 * 3600, events.get(3).getState().getDate().durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(4, reset.size());
    Assert.assertEquals(6 * 3600, reset.get(0).durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(7 * 3600, reset.get(1).durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(8 * 3600, reset.get(2).durationFrom(orbit.getDate()), 1.0e-6);
    Assert.assertEquals(9 * 3600, reset.get(3).durationFrom(orbit.getDate()), 1.0e-6);
}
Also used : LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ArrayList(java.util.ArrayList) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Test(org.junit.Test)

Aggregations

KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)59 Test (org.junit.Test)47 SpacecraftState (org.orekit.propagation.SpacecraftState)41 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)40 AbsoluteDate (org.orekit.time.AbsoluteDate)36 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)34 Propagator (org.orekit.propagation.Propagator)32 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)21 GeodeticPoint (org.orekit.bodies.GeodeticPoint)20 Orbit (org.orekit.orbits.Orbit)20 PVCoordinates (org.orekit.utils.PVCoordinates)15 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)14 OrekitException (org.orekit.errors.OrekitException)13 Frame (org.orekit.frames.Frame)13 TopocentricFrame (org.orekit.frames.TopocentricFrame)12 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)11 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)9 CartesianOrbit (org.orekit.orbits.CartesianOrbit)8 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)8 DateComponents (org.orekit.time.DateComponents)7