Search in sources :

Example 1 with BodyCenterPointing

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

the class FieldSpacecraftStateTest method doTestShiftVsEcksteinHechlerError.

private <T extends RealFieldElement<T>> void doTestShiftVsEcksteinHechlerError(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T mass = zero.add(2500.);
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    final double ae = 6.378137e6;
    final double c20 = -1.08263e-3;
    final double c30 = 2.54e-6;
    final double c40 = 1.62e-6;
    final double c50 = 2.3e-7;
    final double c60 = -5.5e-7;
    // polynomial models for interpolation error in position, velocity, acceleration and attitude
    // these models grow as follows
    // interpolation time (s)    position error (m)   velocity error (m/s)   acceleration error (m/s²)  attitude error (°)
    // 60                        2                    0.07                  0.002               0.00002
    // 120                       12                    0.3                   0.005               0.00009
    // 300                      170                    1.6                   0.012               0.0009
    // 600                     1200                    5.7                   0.024               0.006
    // 900                     3600                   10.6                   0.034               0.02
    // the expected maximum residuals with respect to these models are about 0.4m, 0.5mm/s, 8μm/s² and 3e-6°
    PolynomialFunction pModel = new PolynomialFunction(new double[] { 1.5664070631933846e-01, 7.5504722733047560e-03, -8.2460562451009510e-05, 6.9546332080305580e-06, -1.7045365367533077e-09, -4.2187860791066264e-13 });
    PolynomialFunction vModel = new PolynomialFunction(new double[] { -3.5472364019908720e-04, 1.6568103861124980e-05, 1.9637913327830596e-05, -3.4248792843039766e-09, -5.6565135131014254e-12, 1.4730170946808630e-15 });
    PolynomialFunction aModel = new PolynomialFunction(new double[] { 3.0731707577766896e-06, 3.9770746399850350e-05, 1.9779039254538660e-09, 8.0263328220724900e-12, -1.5600835252366078e-14, 1.1785257001549687e-18 });
    PolynomialFunction rModel = new PolynomialFunction(new double[] { -2.7689062063188115e-06, 1.7406542538258334e-07, 2.5109795349592287e-09, 2.0399322661074575e-11, 9.9126348912426750e-15, -3.5015638905729510e-18 });
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, attitudeLaw, mass, ae, mu, c20, c30, c40, c50, c60);
    FieldAbsoluteDate<T> centerDate = orbit.getDate().shiftedBy(100.0);
    FieldSpacecraftState<T> centerState = propagator.propagate(centerDate);
    double maxResidualP = 0;
    double maxResidualV = 0;
    double maxResidualA = 0;
    double maxResidualR = 0;
    for (T dt = field.getZero(); dt.getReal() < 900.0; dt = dt.add(5)) {
        FieldSpacecraftState<T> shifted = centerState.shiftedBy(dt);
        FieldSpacecraftState<T> propagated = propagator.propagate(centerDate.shiftedBy(dt));
        FieldPVCoordinates<T> dpv = new FieldPVCoordinates<>(propagated.getPVCoordinates(), shifted.getPVCoordinates());
        double residualP = pModel.value(dt.getReal()) - dpv.getPosition().getNorm().getReal();
        double residualV = vModel.value(dt.getReal()) - dpv.getVelocity().getNorm().getReal();
        double residualA = aModel.value(dt.getReal()) - dpv.getAcceleration().getNorm().getReal();
        double residualR = rModel.value(dt.getReal()) - FastMath.toDegrees(FieldRotation.distance(shifted.getAttitude().getRotation(), propagated.getAttitude().getRotation()).getReal());
        maxResidualP = FastMath.max(maxResidualP, FastMath.abs(residualP));
        maxResidualV = FastMath.max(maxResidualV, FastMath.abs(residualV));
        maxResidualA = FastMath.max(maxResidualA, FastMath.abs(residualA));
        maxResidualR = FastMath.max(maxResidualR, FastMath.abs(residualR));
    }
    Assert.assertEquals(0.40, maxResidualP, 0.01);
    Assert.assertEquals(4.9e-4, maxResidualV, 1.0e-5);
    Assert.assertEquals(2.8e-6, maxResidualR, 1.0e-1);
}
Also used : PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 2 with BodyCenterPointing

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

the class FieldSpacecraftStateTest method doTestTransform.

private <T extends RealFieldElement<T>> void doTestTransform(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    double maxDP = 0;
    double maxDV = 0;
    double maxDA = 0;
    for (double t = 0; t < orbit.getKeplerianPeriod().getReal(); t += 60) {
        final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(zero.add(t)));
        final Transform transform = state.toSpacecraftState().toTransform().getInverse();
        PVCoordinates pv = transform.transformPVCoordinates(PVCoordinates.ZERO);
        PVCoordinates dPV = new PVCoordinates(pv, state.getPVCoordinates().toPVCoordinates());
        Vector3D mZDirection = transform.transformVector(Vector3D.MINUS_K);
        double alpha = Vector3D.angle(mZDirection, state.getPVCoordinates().toPVCoordinates().getPosition());
        maxDP = FastMath.max(maxDP, dPV.getPosition().getNorm());
        maxDV = FastMath.max(maxDV, dPV.getVelocity().getNorm());
        maxDA = FastMath.max(maxDA, FastMath.toDegrees(alpha));
    }
    Assert.assertEquals(0.0, maxDP, 1.0e-6);
    Assert.assertEquals(0.0, maxDV, 1.0e-9);
    Assert.assertEquals(0.0, maxDA, 1.0e-12);
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 3 with BodyCenterPointing

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

the class FieldSpacecraftStateTest method doTestAdditionalStates.

private <T extends RealFieldElement<T>> void doTestAdditionalStates(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    T mass = zero.add(2500);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, attitudeLaw, mu, mass);
    final FieldSpacecraftState<T> state = propagator.propagate(orbit.getDate().shiftedBy(60));
    T[] add = MathArrays.buildArray(field, 2);
    add[0] = zero.add(1.);
    add[1] = zero.add(2.);
    final FieldSpacecraftState<T> extended = state.addAdditionalState("test-1", add).addAdditionalState("test-2", zero.add(42.0));
    Assert.assertEquals(0, state.getAdditionalStates().size());
    Assert.assertFalse(state.hasAdditionalState("test-1"));
    try {
        state.getAdditionalState("test-1");
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertEquals(oe.getParts()[0], "test-1");
    }
    try {
        state.ensureCompatibleAdditionalStates(extended);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        extended.ensureCompatibleAdditionalStates(state);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(oe.getSpecifier(), OrekitMessages.UNKNOWN_ADDITIONAL_STATE);
        Assert.assertTrue(oe.getParts()[0].toString().startsWith("test-"));
    }
    try {
        T[] kk = MathArrays.buildArray(field, 7);
        extended.ensureCompatibleAdditionalStates(extended.addAdditionalState("test-2", kk));
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalStateException mise) {
        Assert.assertEquals(LocalizedCoreFormats.DIMENSIONS_MISMATCH, mise.getSpecifier());
        Assert.assertEquals(7, ((Integer) mise.getParts()[0]).intValue());
    }
    Assert.assertEquals(2, extended.getAdditionalStates().size());
    Assert.assertTrue(extended.hasAdditionalState("test-1"));
    Assert.assertTrue(extended.hasAdditionalState("test-2"));
    Assert.assertEquals(1.0, extended.getAdditionalState("test-1")[0].getReal(), 1.0e-15);
    Assert.assertEquals(2.0, extended.getAdditionalState("test-1")[1].getReal(), 1.0e-15);
    Assert.assertEquals(42.0, extended.getAdditionalState("test-2")[0].getReal(), 1.0e-15);
    // test various constructors
    T[] dd = MathArrays.buildArray(field, 1);
    dd[0] = zero.add(-6.0);
    Map<String, T[]> map = new HashMap<String, T[]>();
    map.put("test-3", dd);
    FieldSpacecraftState<T> sO = new FieldSpacecraftState<>(state.getOrbit(), map);
    Assert.assertEquals(-6.0, sO.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOA = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), map);
    Assert.assertEquals(-6.0, sOA.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOM = new FieldSpacecraftState<>(state.getOrbit(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sOAM = new FieldSpacecraftState<>(state.getOrbit(), state.getAttitude(), state.getMass(), map);
    Assert.assertEquals(-6.0, sOAM.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
    FieldSpacecraftState<T> sFromDouble = new FieldSpacecraftState<>(field, sOAM.toSpacecraftState());
    Assert.assertEquals(-6.0, sFromDouble.getAdditionalState("test-3")[0].getReal(), 1.0e-15);
}
Also used : HashMap(java.util.HashMap) DateComponents(org.orekit.time.DateComponents) MathIllegalStateException(org.hipparchus.exception.MathIllegalStateException) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 4 with BodyCenterPointing

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

the class FieldSpacecraftStateTest method doTestDatesConsistency.

private <T extends RealFieldElement<T>> void doTestDatesConsistency(final Field<T> field) throws OrekitException {
    T zero = field.getZero();
    T a = zero.add(rOrbit.getA());
    T e = zero.add(rOrbit.getE());
    T i = zero.add(rOrbit.getI());
    T pa = zero.add(1.9674147913622104);
    T raan = zero.add(FastMath.toRadians(261));
    T lv = zero.add(0);
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(a, e, i, pa, raan, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
    BodyCenterPointing attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
    new FieldSpacecraftState<>(orbit, attitudeLaw.getAttitude(orbit.shiftedBy(zero.add(10.0)), orbit.getDate().shiftedBy(10.0), orbit.getFrame()));
}
Also used : BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) DateComponents(org.orekit.time.DateComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit)

Example 5 with BodyCenterPointing

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

the class SpacecraftStateTest method setUp.

@Before
public void setUp() {
    try {
        Utils.setDataRoot("regular-data");
        double mu = 3.9860047e14;
        double ae = 6.378137e6;
        double c20 = -1.08263e-3;
        double c30 = 2.54e-6;
        double c40 = 1.62e-6;
        double c50 = 2.3e-7;
        double c60 = -5.5e-7;
        mass = 2500;
        double a = 7187990.1979844316;
        double e = 0.5e-4;
        double i = 1.7105407051081795;
        double omega = 1.9674147913622104;
        double OMEGA = FastMath.toRadians(261);
        double lv = 0;
        AbsoluteDate date = new AbsoluteDate(new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
        orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu);
        OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
        attitudeLaw = new BodyCenterPointing(orbit.getFrame(), earth);
        propagator = new EcksteinHechlerPropagator(orbit, attitudeLaw, mass, ae, mu, c20, c30, c40, c50, c60);
    } catch (OrekitException oe) {
        Assert.fail(oe.getLocalizedMessage());
    }
}
Also used : EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) BodyCenterPointing(org.orekit.attitudes.BodyCenterPointing) DateComponents(org.orekit.time.DateComponents) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Aggregations

BodyCenterPointing (org.orekit.attitudes.BodyCenterPointing)10 DateComponents (org.orekit.time.DateComponents)9 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)5 OrekitException (org.orekit.errors.OrekitException)5 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)5 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)5 Before (org.junit.Before)4 AbsoluteDate (org.orekit.time.AbsoluteDate)4 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)2 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)2 FieldKeplerianPropagator (org.orekit.propagation.analytical.FieldKeplerianPropagator)2 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)2 HashMap (java.util.HashMap)1 PolynomialFunction (org.hipparchus.analysis.polynomials.PolynomialFunction)1 MathIllegalStateException (org.hipparchus.exception.MathIllegalStateException)1 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)1 Test (org.junit.Test)1 Frame (org.orekit.frames.Frame)1