Search in sources :

Example 31 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class KeplerianPropagatorTest method wrongAttitude.

@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
    KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 5918362126173997016L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    KeplerianPropagator propagator = new KeplerianPropagator(orbit, wrongLaw);
    propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 32 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class FieldOfViewDetectorTest method testStopOnExit.

/**
 * check the default behavior to stop propagation on FoV exit.
 */
@Test
public void testStopOnExit() 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);
    AttitudeProvider attitude = new NadirPointing(eci, earth);
    // action
    FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, pi / 3, 16, 0);
    FieldOfViewDetector fovDetector = new FieldOfViewDetector(topo, fov).withMaxCheck(5.0);
    EventsLogger logger = new EventsLogger();
    Propagator prop = new KeplerianPropagator(orbit, attitude);
    prop.addEventDetector(logger.monitorDetector(fovDetector));
    prop.propagate(endDate);
    List<LoggedEvent> actual = logger.getLoggedEvents();
    // verify
    // check we have an entry and an exit event.
    Assert.assertEquals(2, actual.size());
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 33 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class Ephemeris method basicPropagate.

@Override
public /**
 * {@inheritDoc}
 */
SpacecraftState basicPropagate(final AbsoluteDate date) throws OrekitException {
    final SpacecraftState evaluatedState;
    final AbsoluteDate central;
    if (date.compareTo(minDate) < 0 && FastMath.abs(date.durationFrom(minDate)) <= extrapolationThreshold) {
        // avoid TimeStampedCacheException as we are still within the tolerance before minDate
        central = minDate;
    } else if (date.compareTo(maxDate) > 0 && FastMath.abs(date.durationFrom(maxDate)) <= extrapolationThreshold) {
        // avoid TimeStampedCacheException as we are still within the tolerance after maxDate
        central = maxDate;
    } else {
        central = date;
    }
    final List<SpacecraftState> neighbors = cache.getNeighbors(central).collect(Collectors.toList());
    evaluatedState = neighbors.get(0).interpolate(date, neighbors);
    final AttitudeProvider attitudeProvider = getAttitudeProvider();
    if (attitudeProvider == null) {
        return evaluatedState;
    } else {
        pvProvider.setCurrentState(evaluatedState);
        final Attitude calculatedAttitude = attitudeProvider.getAttitude(pvProvider, date, evaluatedState.getFrame());
        return new SpacecraftState(evaluatedState.getOrbit(), calculatedAttitude, evaluatedState.getMass());
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) Attitude(org.orekit.attitudes.Attitude) AbsoluteDate(org.orekit.time.AbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Example 34 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class FieldEcksteinHechlerPropagatorTest method doWrongAttitude.

private <T extends RealFieldElement<T>> void doWrongAttitude(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(1.0e10), zero.add(1.0e-4), zero.add(1.0e-2), zero, zero, zero, PositionAngle.TRUE, FramesFactory.getEME2000(), date, 3.986004415e14);
    final DummyLocalizable gasp = new DummyLocalizable("gasp");
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        @Override
        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(gasp, new RuntimeException());
        }

        @Override
        public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
            throw new OrekitException(gasp, new RuntimeException());
        }
    };
    try {
        FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, wrongLaw, provider);
        propagator.propagate(date.shiftedBy(10.0));
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertSame(gasp, oe.getSpecifier());
    }
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Example 35 with AttitudeProvider

use of org.orekit.attitudes.AttitudeProvider in project Orekit by CS-SI.

the class FieldKeplerianPropagatorTest method doTestWrongAttitude.

private <T extends RealFieldElement<T>> void doTestWrongAttitude(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(1.0e10), zero.add(1.0e-4), zero.add(1.0e-2), zero, zero, zero, PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        @Override
        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }

        @Override
        public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, wrongLaw);
    propagator.propagate(new FieldAbsoluteDate<>(field).shiftedBy(10.0));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Aggregations

AttitudeProvider (org.orekit.attitudes.AttitudeProvider)36 Test (org.junit.Test)29 AbsoluteDate (org.orekit.time.AbsoluteDate)21 LofOffset (org.orekit.attitudes.LofOffset)20 SpacecraftState (org.orekit.propagation.SpacecraftState)17 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)16 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)15 ConstantThrustManeuver (org.orekit.forces.maneuvers.ConstantThrustManeuver)15 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 InertialProvider (org.orekit.attitudes.InertialProvider)13 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)12 Orbit (org.orekit.orbits.Orbit)12 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)10 OrekitException (org.orekit.errors.OrekitException)10 CartesianOrbit (org.orekit.orbits.CartesianOrbit)10 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)9 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)9 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)8 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)8 DateComponents (org.orekit.time.DateComponents)8