Search in sources :

Example 1 with LOFType

use of org.orekit.frames.LOFType in project Orekit by CS-SI.

the class LofOffsetPointingTest method testTypesField.

@Test
public void testTypesField() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
    KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
    for (final LOFType type : LOFType.values()) {
        RotationOrder order = RotationOrder.ZXY;
        double alpha1 = 0.123;
        double alpha2 = 0.456;
        double alpha3 = 0.789;
        LofOffset law = new LofOffset(orbit.getFrame(), type, order, alpha1, alpha2, alpha3);
        final Vector3D dir;
        switch(type) {
            case TNW:
                dir = Vector3D.PLUS_J;
                break;
            case QSW:
            case LVLH:
                dir = Vector3D.MINUS_I;
                break;
            case VVLH:
                dir = Vector3D.PLUS_K;
                break;
            default:
                // VNC
                dir = Vector3D.MINUS_K;
        }
        LofOffsetPointing lop = new LofOffsetPointing(orbit.getFrame(), earthSpheric, law, dir);
        checkField(Decimal64Field.getInstance(), lop, orbit, date, orbit.getFrame());
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) LOFType(org.orekit.frames.LOFType) RotationOrder(org.hipparchus.geometry.euclidean.threed.RotationOrder) DateComponents(org.orekit.time.DateComponents) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 2 with LOFType

use of org.orekit.frames.LOFType in project Orekit by CS-SI.

the class LofOffsetTest method testTypesField.

@Test
public void testTypesField() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
    KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
    for (final LOFType type : LOFType.values()) {
        RotationOrder order = RotationOrder.ZXY;
        double alpha1 = 0.123;
        double alpha2 = 0.456;
        double alpha3 = 0.789;
        LofOffset law = new LofOffset(orbit.getFrame(), type, order, alpha1, alpha2, alpha3);
        checkField(Decimal64Field.getInstance(), law, orbit, date, orbit.getFrame());
    }
}
Also used : LOFType(org.orekit.frames.LOFType) RotationOrder(org.hipparchus.geometry.euclidean.threed.RotationOrder) DateComponents(org.orekit.time.DateComponents) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 3 with LOFType

use of org.orekit.frames.LOFType in project Orekit by CS-SI.

the class TabulatedLofOffsetTest method testSerialization.

@Test
public void testSerialization() throws OrekitException, IOException, ClassNotFoundException {
    // create a sample from Yaw compensation law
    final LOFType type = LOFType.VNC;
    final List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
    final AttitudeProvider yawCompensLaw = new YawCompensation(orbit.getFrame(), new NadirPointing(orbit.getFrame(), earth));
    final Propagator originalPropagator = new KeplerianPropagator(orbit);
    originalPropagator.setAttitudeProvider(yawCompensLaw);
    originalPropagator.setMasterMode(10.0, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            Rotation offsetAtt = currentState.getAttitude().getRotation();
            LofOffset aligned = new LofOffset(currentState.getFrame(), type);
            Rotation alignedAtt = aligned.getAttitude(currentState.getOrbit(), currentState.getDate(), currentState.getFrame()).getRotation();
            Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
            sample.add(new TimeStampedAngularCoordinates(currentState.getDate(), offsetProper, Vector3D.ZERO, Vector3D.ZERO));
        }
    });
    originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
    originalPropagator.setSlaveMode();
    // use the sample and generate an ephemeris
    final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
    final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
    rebuildingPropagator.setAttitudeProvider(tabulated);
    rebuildingPropagator.setEphemerisMode();
    rebuildingPropagator.propagate(orbit.getDate().shiftedBy(5));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(rebuildingPropagator.getGeneratedEphemeris());
    // even despite we propagated only 5 seconds, the attitude sample is huge
    Assert.assertTrue(bos.size() > 17000);
    Assert.assertTrue(bos.size() < 18000);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    TabulatedLofOffset deserialized = (TabulatedLofOffset) ((BoundedPropagator) ois.readObject()).getAttitudeProvider();
    Assert.assertEquals(sample.size(), deserialized.getTable().size());
}
Also used : ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) ByteArrayInputStream(java.io.ByteArrayInputStream) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 4 with LOFType

use of org.orekit.frames.LOFType in project Orekit by CS-SI.

the class TabulatedLofOffsetTest method testYawCompensation.

@Test
public void testYawCompensation() throws OrekitException {
    // create a sample from Yaw compensation law
    final LOFType type = LOFType.VNC;
    final List<TimeStampedAngularCoordinates> sample = new ArrayList<TimeStampedAngularCoordinates>();
    final AttitudeProvider yawCompensLaw = new YawCompensation(orbit.getFrame(), new NadirPointing(orbit.getFrame(), earth));
    final Propagator originalPropagator = new KeplerianPropagator(orbit);
    originalPropagator.setAttitudeProvider(yawCompensLaw);
    originalPropagator.setMasterMode(1.0, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            Rotation offsetAtt = currentState.getAttitude().getRotation();
            LofOffset aligned = new LofOffset(currentState.getFrame(), type);
            Rotation alignedAtt = aligned.getAttitude(currentState.getOrbit(), currentState.getDate(), currentState.getFrame()).getRotation();
            Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
            sample.add(new TimeStampedAngularCoordinates(currentState.getDate(), offsetProper, Vector3D.ZERO, Vector3D.ZERO));
        }
    });
    originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
    originalPropagator.setSlaveMode();
    // use the sample and compare it to original
    final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample, 6, AngularDerivativesFilter.USE_RR);
    final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
    rebuildingPropagator.setAttitudeProvider(tabulated);
    rebuildingPropagator.setMasterMode(0.3, new OrekitFixedStepHandler() {

        public void handleStep(final SpacecraftState currentState, final boolean isLast) throws OrekitException {
            final SpacecraftState rebuilt = originalPropagator.propagate(currentState.getDate());
            final Rotation r1 = currentState.getAttitude().getRotation();
            final Rotation r2 = rebuilt.getAttitude().getRotation();
            Assert.assertEquals(0.0, Rotation.distance(r1, r2), 7.0e-6);
            checkField(Decimal64Field.getInstance(), tabulated, currentState.getOrbit(), currentState.getDate(), currentState.getFrame());
        }
    });
    rebuildingPropagator.propagate(orbit.getDate().shiftedBy(50), orbit.getDate().shiftedBy(1950));
}
Also used : ArrayList(java.util.ArrayList) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) LOFType(org.orekit.frames.LOFType) Propagator(org.orekit.propagation.Propagator) BoundedPropagator(org.orekit.propagation.BoundedPropagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OrekitException(org.orekit.errors.OrekitException) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Test(org.junit.Test)

Example 5 with LOFType

use of org.orekit.frames.LOFType in project Orekit by CS-SI.

the class TabulatedLofOffsetTest method testConstantOffset.

@Test
public void testConstantOffset() throws OrekitException {
    RandomGenerator random = new Well19937a(0x1199d4bb8f53d2b6l);
    for (LOFType type : LOFType.values()) {
        for (int i = 0; i < 100; ++i) {
            double a1 = random.nextDouble() * MathUtils.TWO_PI;
            double a2 = random.nextDouble() * MathUtils.TWO_PI;
            double a3 = random.nextDouble() * MathUtils.TWO_PI;
            LofOffset law = new LofOffset(orbit.getFrame(), type, RotationOrder.XYZ, a1, a2, a3);
            Rotation offsetAtt = law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
            LofOffset aligned = new LofOffset(orbit.getFrame(), type);
            Rotation alignedAtt = aligned.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
            Rotation offsetProper = offsetAtt.compose(alignedAtt.revert(), RotationConvention.VECTOR_OPERATOR);
            TabulatedLofOffset tabulated = new TabulatedLofOffset(orbit.getFrame(), type, Arrays.asList(new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(-10), offsetProper, Vector3D.ZERO, Vector3D.ZERO), new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(0), offsetProper, Vector3D.ZERO, Vector3D.ZERO), new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(+10), offsetProper, Vector3D.ZERO, Vector3D.ZERO)), 2, AngularDerivativesFilter.USE_R);
            Rotation rebuilt = tabulated.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
            Assert.assertEquals(0.0, Rotation.distance(offsetAtt, rebuilt), 1.2e-15);
        }
    }
}
Also used : LOFType(org.orekit.frames.LOFType) Well19937a(org.hipparchus.random.Well19937a) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 LOFType (org.orekit.frames.LOFType)5 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)3 TimeStampedAngularCoordinates (org.orekit.utils.TimeStampedAngularCoordinates)3 ArrayList (java.util.ArrayList)2 RotationOrder (org.hipparchus.geometry.euclidean.threed.RotationOrder)2 OrekitException (org.orekit.errors.OrekitException)2 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)2 BoundedPropagator (org.orekit.propagation.BoundedPropagator)2 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)2 Propagator (org.orekit.propagation.Propagator)2 SpacecraftState (org.orekit.propagation.SpacecraftState)2 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)2 OrekitFixedStepHandler (org.orekit.propagation.sampling.OrekitFixedStepHandler)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 DateComponents (org.orekit.time.DateComponents)2 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)2 TimeComponents (org.orekit.time.TimeComponents)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1