Search in sources :

Example 1 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class AttitudesSequenceTest method testResetDuringTransitionForward.

@Test
public void testResetDuringTransitionForward() throws OrekitException {
    // Initial state definition : date, orbit
    final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final double transitionTime = 250.0;
    final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
    final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
    final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
    final List<AbsoluteDate> nadirToTarget = new ArrayList<>();
    attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, (previous, next, state) -> nadirToTarget.add(state.getDate()));
    final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
    propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
    propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
    propagator.setAttitudeProvider(attitudesSequence);
    attitudesSequence.registerSwitchEvents(propagator);
    propagator.propagate(initialDate.shiftedBy(6000));
    // check that if we restart a forward propagation from an intermediate state
    // we properly get an interpolated attitude despite we missed the event trigger
    final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
    SpacecraftState state = propagator.propagate(midTransition.shiftedBy(-60), midTransition);
    Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
    Rotation targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
    final double reorientationAngle = Rotation.distance(nadirR, targetR);
    Assert.assertEquals(0.5 * reorientationAngle, Rotation.distance(state.getAttitude().getRotation(), nadirR), 0.03 * reorientationAngle);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ArrayList(java.util.ArrayList) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 2 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class AttitudesSequenceTest method testOutOfSyncCalls.

@Test
public void testOutOfSyncCalls() throws OrekitException {
    // Initial state definition : date, orbit
    final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final double transitionTime = 250.0;
    final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
    final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
    final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
    final Handler nadirToTarget = new Handler(nadirPointing, targetPointing);
    attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, nadirToTarget);
    final Handler targetToNadir = new Handler(targetPointing, nadirPointing);
    attitudesSequence.addSwitchingCondition(targetPointing, nadirPointing, eventDetector, false, true, transitionTime, AngularDerivativesFilter.USE_RR, targetToNadir);
    final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
    final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
    propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
    propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
    propagator.setAttitudeProvider(attitudesSequence);
    attitudesSequence.registerSwitchEvents(propagator);
    propagator.setMasterMode(10, (state, isLast) -> {
        Attitude nadirAttitude = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        Attitude targetAttitude = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        Attitude stateAttitude = state.getAttitude();
        if (nadirToTarget.dates.isEmpty() || state.getDate().durationFrom(nadirToTarget.dates.get(0)) < 0) {
            // we are stabilized in nadir pointing, before first switch
            checkEqualAttitudes(nadirAttitude, stateAttitude);
        } else if (state.getDate().durationFrom(nadirToTarget.dates.get(0)) <= transitionTime) {
            // we are in transition from nadir to target
            checkBetweenAttitudes(nadirAttitude, targetAttitude, stateAttitude);
        } else if (targetToNadir.dates.isEmpty() || state.getDate().durationFrom(targetToNadir.dates.get(0)) < 0) {
            // we are stabilized in target pointing between the two switches
            checkEqualAttitudes(targetAttitude, stateAttitude);
        } else if (state.getDate().durationFrom(targetToNadir.dates.get(0)) <= transitionTime) {
            // we are in transition from target to nadir
            checkBetweenAttitudes(targetAttitude, nadirAttitude, stateAttitude);
        } else {
            // we are stabilized back in nadir pointing, after second switch
            checkEqualAttitudes(nadirAttitude, stateAttitude);
        }
    });
    propagator.propagate(initialDate.shiftedBy(6000));
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldOrekitFixedStepHandler(org.orekit.propagation.sampling.FieldOrekitFixedStepHandler) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) EventHandler(org.orekit.propagation.events.handlers.EventHandler) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 3 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class OrekitEphemerisFileTest method testWritingToOEM.

@Test
public void testWritingToOEM() throws OrekitException, IOException {
    final double muTolerance = 1e-12;
    final double positionTolerance = 1e-8;
    final double velocityTolerance = 1e-8;
    final String satId = "SATELLITE1";
    final double sma = 10000000;
    final double inc = Math.toRadians(45.0);
    final double ecc = 0.001;
    final double raan = 0.0;
    final double pa = 0.0;
    final double ta = 0.0;
    final AbsoluteDate date = new AbsoluteDate();
    final Frame frame = FramesFactory.getGCRF();
    final CelestialBody body = CelestialBodyFactory.getEarth();
    final double mu = body.getGM();
    KeplerianOrbit initialOrbit = new KeplerianOrbit(sma, ecc, inc, pa, raan, ta, PositionAngle.TRUE, frame, date, mu);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    final double propagationDurationSeconds = 86400.0;
    final double stepSizeSeconds = 60.0;
    List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    for (double dt = 0.0; dt < propagationDurationSeconds; dt += stepSizeSeconds) {
        states.add(propagator.propagate(date.shiftedBy(dt)));
    }
    OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
    OrekitSatelliteEphemeris satellite = ephemerisFile.addSatellite(satId);
    satellite.addNewSegment(states);
    String tempOemFile = Files.createTempFile("OrekitEphemerisFileTest", ".oem").toString();
    new OEMWriter().write(tempOemFile, ephemerisFile);
    EphemerisFile ephemerisFromFile = new OEMParser().parse(tempOemFile);
    Files.delete(Paths.get(tempOemFile));
    EphemerisSegment segment = ephemerisFromFile.getSatellites().get(satId).getSegments().get(0);
    assertEquals(states.get(0).getDate(), segment.getStart());
    assertEquals(states.get(states.size() - 1).getDate(), segment.getStop());
    assertEquals(states.size(), segment.getCoordinates().size());
    assertEquals(frame, segment.getFrame());
    assertEquals(body.getName().toUpperCase(), segment.getFrameCenterString());
    assertEquals(body.getGM(), segment.getMu(), muTolerance);
    for (int i = 0; i < states.size(); i++) {
        TimeStampedPVCoordinates expected = states.get(i).getPVCoordinates();
        TimeStampedPVCoordinates actual = segment.getCoordinates().get(i);
        assertEquals(expected.getDate(), actual.getDate());
        assertEquals(0.0, Vector3D.distance(expected.getPosition(), actual.getPosition()), positionTolerance);
        assertEquals(0.0, Vector3D.distance(expected.getVelocity(), actual.getVelocity()), velocityTolerance);
    }
    // test ingested ephemeris generates access intervals
    final OneAxisEllipsoid parentShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final double latitude = 0.0;
    final double longitude = 0.0;
    final double altitude = 0.0;
    final GeodeticPoint point = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame topo = new TopocentricFrame(parentShape, point, "testPoint1");
    final ElevationDetector elevationDetector = new ElevationDetector(topo);
    final EphemerisSegmentPropagator ephemerisSegmentPropagator = new EphemerisSegmentPropagator(segment);
    final EventsLogger lookupLogger = new EventsLogger();
    ephemerisSegmentPropagator.addEventDetector(lookupLogger.monitorDetector(elevationDetector));
    final EventsLogger referenceLogger = new EventsLogger();
    propagator.clearEventsDetectors();
    propagator.addEventDetector(referenceLogger.monitorDetector(elevationDetector));
    propagator.propagate(segment.getStart(), segment.getStop());
    ephemerisSegmentPropagator.propagate(segment.getStart(), segment.getStop());
    final double dateEpsilon = 1.0e-9;
    assertTrue(referenceLogger.getLoggedEvents().size() > 0);
    assertEquals(referenceLogger.getLoggedEvents().size(), lookupLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = lookupLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final Propagator embeddedPropagator = segment.getPropagator();
    final EventsLogger embeddedPropLogger = new EventsLogger();
    embeddedPropagator.addEventDetector(embeddedPropLogger.monitorDetector(elevationDetector));
    embeddedPropagator.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), embeddedPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = embeddedPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final List<SpacecraftState> readInStates = new ArrayList<SpacecraftState>();
    segment.getCoordinates().forEach(c -> {
        try {
            readInStates.add(new SpacecraftState(new CartesianOrbit(c, frame, mu)));
        } catch (IllegalArgumentException | OrekitException e) {
            fail(e.getLocalizedMessage());
        }
    });
    final int interpolationPoints = 5;
    Ephemeris directEphemProp = new Ephemeris(readInStates, interpolationPoints);
    final EventsLogger directEphemPropLogger = new EventsLogger();
    directEphemProp.addEventDetector(directEphemPropLogger.monitorDetector(elevationDetector));
    directEphemProp.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), directEphemPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = directEphemPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ElevationDetector(org.orekit.propagation.events.ElevationDetector) ArrayList(java.util.ArrayList) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) EphemerisSegment(org.orekit.files.general.EphemerisFile.EphemerisSegment) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) CelestialBody(org.orekit.bodies.CelestialBody) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) OEMParser(org.orekit.files.ccsds.OEMParser) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OEMWriter(org.orekit.files.ccsds.OEMWriter) EventsLogger(org.orekit.propagation.events.EventsLogger) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) Ephemeris(org.orekit.propagation.analytical.Ephemeris) Test(org.junit.Test)

Example 4 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector in project Orekit by CS-SI.

the class KeplerianPropagatorTest method setting.

@Test
public void setting() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit);
    final OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame topo = new TopocentricFrame(earthShape, new GeodeticPoint(0.389, -2.962, 0), null);
    propagator.addEventDetector(new ElevationDetector(60, AbstractDetector.DEFAULT_THRESHOLD, topo).withConstantElevation(0.09));
    AbsoluteDate farTarget = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
    SpacecraftState propagated = propagator.propagate(farTarget);
    final double elevation = topo.getElevation(propagated.getPVCoordinates().getPosition(), propagated.getFrame(), propagated.getDate());
    final double zVelocity = propagated.getPVCoordinates(topo).getVelocity().getZ();
    Assert.assertTrue(farTarget.durationFrom(propagated.getDate()) > 7800.0);
    Assert.assertTrue(farTarget.durationFrom(propagated.getDate()) < 7900.0);
    Assert.assertEquals(0.09, elevation, 1.0e-9);
    Assert.assertTrue(zVelocity < 0);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ElevationDetector(org.orekit.propagation.events.ElevationDetector) TopocentricFrame(org.orekit.frames.TopocentricFrame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 5 with ElevationDetector

use of org.orekit.propagation.events.ElevationDetector 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)

Aggregations

GeodeticPoint (org.orekit.bodies.GeodeticPoint)8 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)8 TopocentricFrame (org.orekit.frames.TopocentricFrame)8 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)8 ElevationDetector (org.orekit.propagation.events.ElevationDetector)8 AbsoluteDate (org.orekit.time.AbsoluteDate)8 Test (org.junit.Test)7 SpacecraftState (org.orekit.propagation.SpacecraftState)7 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 Orbit (org.orekit.orbits.Orbit)4 PVCoordinates (org.orekit.utils.PVCoordinates)4 ArrayList (java.util.ArrayList)3 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)3 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)3 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)3 HolmesFeatherstoneAttractionModel (org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel)3 ICGEMFormatReader (org.orekit.forces.gravity.potential.ICGEMFormatReader)3 Frame (org.orekit.frames.Frame)3 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)3