Search in sources :

Example 26 with LofOffset

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

the class FieldOfViewTest method testRollPitchYawHexagonalFootprint.

@Test
public void testRollPitchYawHexagonalFootprint() 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 LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(10), FastMath.toRadians(20), FastMath.toRadians(5)));
    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(48.0026, FastMath.toDegrees(minEl), 0.001);
    Assert.assertEquals(60.1975, FastMath.toDegrees(maxEl), 0.001);
    Assert.assertEquals(1221543.6, minDist, 1.0);
    Assert.assertEquals(1804921.6, maxDist, 1.0);
}
Also used : 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) LofOffset(org.orekit.attitudes.LofOffset) Test(org.junit.Test)

Example 27 with LofOffset

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

the class FootprintOverlapDetectorTest method testRightForwardView.

@Test
public void testRightForwardView() throws OrekitException, IOException {
    propagator.setAttitudeProvider(new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(-20.0), FastMath.toRadians(+20.0), 0.0));
    // observe continental France plus Corsica
    final SphericalPolygonsSet france = buildFrance();
    // square field of view along Z axis (which is pointing sideways), aperture 5°, 0° margin
    final FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(2.5), 4, 0.0);
    final FootprintOverlapDetector detector = new FootprintOverlapDetector(fov, earth, france, 50000.0).withMaxCheck(1.0).withThreshold(1.0e-6).withHandler(new ContinueOnEvent<FootprintOverlapDetector>());
    final EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(detector));
    // Extrapolate from the initial to the final date
    propagator.propagate(initialOrbit.getDate().shiftedBy(635000), initialOrbit.getDate().shiftedBy(735000));
    List<LoggedEvent> events = logger.getLoggedEvents();
    Assert.assertEquals(8, events.size());
    // the first two consecutive close events occur during the same ascending orbit
    // we first see Corsica, then lose visibility over the see, then see continental France
    // above Mediterranean see, between Illes Balears and Sardigna,
    // pointing to Corsica towards North-East
    checkEventPair(events.get(0), events.get(1), 639010.0775, 33.9434, 39.2168, 6.5980, 42.0671, 9.0543);
    // above Saint-Chamond (Loire), pointing near Saint-Dié-des-Vosges (Vosges) towards North-East
    checkEventPair(events.get(2), events.get(3), 639111.1399, 40.8032, 45.4637, 4.5075, 48.3487, 7.1733);
    // event is on a descending orbit, so the pointing direction,
    // taking roll and pitch offsets, is towards South-West with respect to spacecraft
    // above English Channel, pointing near Hanvec (Finistère) towards South-West
    checkEventPair(events.get(4), events.get(5), 687772.4531, 27.0852, 50.2693, 0.0493, 48.3243, -4.1510);
    // event on an ascending orbit
    // above Atlantic ocean, pointing near to île d'Oléron (Charente-Maritime) towards North-East
    checkEventPair(events.get(6), events.get(7), 727696.1033, 113.8829, 42.9785, -4.0426, 45.8492, -1.4656);
}
Also used : LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) SphericalPolygonsSet(org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet) LofOffset(org.orekit.attitudes.LofOffset) Test(org.junit.Test)

Example 28 with LofOffset

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

the class ConstantThrustManeuverTest method testInertialManeuver.

@Test
public void testInertialManeuver() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    final double duration = 3653.99;
    final double f = 420;
    final double delta = FastMath.toRadians(-7.4978);
    final double alpha = FastMath.toRadians(351);
    final AttitudeProvider inertialLaw = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
    final AttitudeProvider lofLaw = new LofOffset(orbit.getFrame(), LOFType.VNC);
    final SpacecraftState initialState = new SpacecraftState(orbit, inertialLaw.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuverWithoutOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
    Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
    // reference propagation:
    // propagator already uses inertial law
    // maneuver does not need to override it to get an inertial maneuver
    double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
    AdaptiveStepsizeIntegrator integrator1 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator1.setInitialStepSize(60);
    final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
    propagator1.setInitialState(initialState);
    propagator1.setAttitudeProvider(inertialLaw);
    propagator1.addForceModel(maneuverWithoutOverride);
    final SpacecraftState finalState1 = propagator1.propagate(fireDate.shiftedBy(3800));
    // test propagation:
    // propagator uses a LOF-aligned law
    // maneuver needs to override it to get an inertial maneuver
    final ConstantThrustManeuver maneuverWithOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, inertialLaw, Vector3D.PLUS_I);
    Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
    AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator2.setInitialStepSize(60);
    final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
    propagator2.setInitialState(initialState);
    propagator2.setAttitudeProvider(lofLaw);
    propagator2.addForceModel(maneuverWithOverride);
    final SpacecraftState finalState2 = propagator2.propagate(finalState1.getDate());
    Assert.assertThat(finalState2.getPVCoordinates(), OrekitMatchers.pvCloseTo(finalState1.getPVCoordinates(), 1.0e-10));
    // intentionally wrong propagation, that will produce a very different state
    // propagator uses LOF attitude,
    // maneuver forget to override it, so maneuver will be LOF-aligned in this case
    AdaptiveStepsizeIntegrator integrator3 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
    integrator3.setInitialStepSize(60);
    final NumericalPropagator propagator3 = new NumericalPropagator(integrator3);
    propagator3.setInitialState(initialState);
    propagator3.setAttitudeProvider(lofLaw);
    propagator3.addForceModel(maneuverWithoutOverride);
    final SpacecraftState finalState3 = propagator3.propagate(finalState1.getDate());
    Assert.assertEquals(345859.0, Vector3D.distance(finalState1.getPVCoordinates().getPosition(), finalState3.getPVCoordinates().getPosition()), 1.0);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) InertialProvider(org.orekit.attitudes.InertialProvider) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldNumericalPropagator(org.orekit.propagation.numerical.FieldNumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) LofOffset(org.orekit.attitudes.LofOffset) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) AbstractLegacyForceModelTest(org.orekit.forces.AbstractLegacyForceModelTest) Test(org.junit.Test)

Example 29 with LofOffset

use of org.orekit.attitudes.LofOffset 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 30 with LofOffset

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

the class ImpulseManeuverTest method testInclinationManeuver.

@Test
public void testInclinationManeuver() throws OrekitException {
    final Orbit initialOrbit = new KeplerianOrbit(24532000.0, 0.72, 0.3, FastMath.PI, 0.4, 2.0, PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2008, 06, 23), new TimeComponents(14, 18, 37), TimeScalesFactory.getUTC()), 3.986004415e14);
    final double a = initialOrbit.getA();
    final double e = initialOrbit.getE();
    final double i = initialOrbit.getI();
    final double mu = initialOrbit.getMu();
    final double vApo = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
    double dv = 0.99 * FastMath.tan(i) * vApo;
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VVLH));
    propagator.addEventDetector(new ImpulseManeuver<NodeDetector>(new NodeDetector(initialOrbit, FramesFactory.getEME2000()), new Vector3D(dv, Vector3D.PLUS_J), 400.0));
    SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000));
    Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6);
}
Also used : KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NodeDetector(org.orekit.propagation.events.NodeDetector) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) LofOffset(org.orekit.attitudes.LofOffset) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

LofOffset (org.orekit.attitudes.LofOffset)58 Test (org.junit.Test)52 SpacecraftState (org.orekit.propagation.SpacecraftState)37 Orbit (org.orekit.orbits.Orbit)30 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)29 AbsoluteDate (org.orekit.time.AbsoluteDate)29 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)26 CartesianOrbit (org.orekit.orbits.CartesianOrbit)20 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)18 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)17 CircularOrbit (org.orekit.orbits.CircularOrbit)15 Propagator (org.orekit.propagation.Propagator)13 DateComponents (org.orekit.time.DateComponents)13 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)12 TimeComponents (org.orekit.time.TimeComponents)12 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)11 ObservedMeasurement (org.orekit.estimation.measurements.ObservedMeasurement)9 BoundedPropagator (org.orekit.propagation.BoundedPropagator)9 NumericalPropagatorBuilder (org.orekit.propagation.conversion.NumericalPropagatorBuilder)9 Context (org.orekit.estimation.Context)8