Search in sources :

Example 1 with Attitude

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

the class AbstractParametricAcceleration method acceleration.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D acceleration(final SpacecraftState state, final double[] parameters) throws OrekitException {
    final Vector3D inertialDirection;
    if (isInertial) {
        // the acceleration direction is already defined in the inertial frame
        inertialDirection = direction;
    } else {
        final Attitude attitude;
        if (attitudeOverride == null) {
            // the acceleration direction is defined in spacecraft frame as set by the propagator
            attitude = state.getAttitude();
        } else {
            // the acceleration direction is defined in a dedicated frame
            attitude = attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        }
        inertialDirection = attitude.getRotation().applyInverseTo(direction);
    }
    return new Vector3D(signedAmplitude(state, parameters), inertialDirection);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Attitude(org.orekit.attitudes.Attitude) FieldAttitude(org.orekit.attitudes.FieldAttitude)

Example 2 with Attitude

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

the class SpacecraftState method interpolate.

/**
 * {@inheritDoc}
 * <p>
 * The additional states that are interpolated are the ones already present
 * in the instance. The sample instances must therefore have at least the same
 * additional states has the instance. They may have more additional states,
 * but the extra ones will be ignored.
 * </p>
 * <p>
 * As this implementation of interpolation is polynomial, it should be used only
 * with small samples (about 10-20 points) in order to avoid <a
 * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's phenomenon</a>
 * and numerical problems (including NaN appearing).
 * </p>
 */
public SpacecraftState interpolate(final AbsoluteDate date, final Stream<SpacecraftState> sample) throws OrekitException {
    // prepare interpolators
    final List<Orbit> orbits = new ArrayList<>();
    final List<Attitude> attitudes = new ArrayList<>();
    final HermiteInterpolator massInterpolator = new HermiteInterpolator();
    final Map<String, HermiteInterpolator> additionalInterpolators = new HashMap<String, HermiteInterpolator>(additional.size());
    for (final String name : additional.keySet()) {
        additionalInterpolators.put(name, new HermiteInterpolator());
    }
    // extract sample data
    try {
        sample.forEach(state -> {
            try {
                final double deltaT = state.getDate().durationFrom(date);
                orbits.add(state.getOrbit());
                attitudes.add(state.getAttitude());
                massInterpolator.addSamplePoint(deltaT, new double[] { state.getMass() });
                for (final Map.Entry<String, HermiteInterpolator> entry : additionalInterpolators.entrySet()) {
                    entry.getValue().addSamplePoint(deltaT, state.getAdditionalState(entry.getKey()));
                }
            } catch (OrekitException oe) {
                throw new OrekitExceptionWrapper(oe);
            }
        });
    } catch (OrekitExceptionWrapper oew) {
        throw oew.getException();
    }
    // perform interpolations
    final Orbit interpolatedOrbit = orbit.interpolate(date, orbits);
    final Attitude interpolatedAttitude = attitude.interpolate(date, attitudes);
    final double interpolatedMass = massInterpolator.value(0)[0];
    final Map<String, double[]> interpolatedAdditional;
    if (additional.isEmpty()) {
        interpolatedAdditional = null;
    } else {
        interpolatedAdditional = new HashMap<String, double[]>(additional.size());
        for (final Map.Entry<String, HermiteInterpolator> entry : additionalInterpolators.entrySet()) {
            interpolatedAdditional.put(entry.getKey(), entry.getValue().value(0));
        }
    }
    // create the complete interpolated state
    return new SpacecraftState(interpolatedOrbit, interpolatedAttitude, interpolatedMass, interpolatedAdditional);
}
Also used : OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) Orbit(org.orekit.orbits.Orbit) Attitude(org.orekit.attitudes.Attitude) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HermiteInterpolator(org.hipparchus.analysis.interpolation.HermiteInterpolator) OrekitException(org.orekit.errors.OrekitException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Attitude

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

the class SpacecraftStateTest method testDateConsistencyClose.

/**
 * Check orbit and attitude dates can be off by a few ulps. I see this when using
 * FixedRate attitude provider.
 */
@Test
public void testDateConsistencyClose() throws OrekitException {
    // setup
    Orbit orbit10Shifts = orbit;
    for (int i = 0; i < 10; i++) {
        orbit10Shifts = orbit10Shifts.shiftedBy(0.1);
    }
    final Orbit orbit1Shift = orbit.shiftedBy(1);
    Attitude shiftedAttitude = attitudeLaw.getAttitude(orbit1Shift, orbit1Shift.getDate(), orbit.getFrame());
    // verify dates are very close, but not equal
    Assert.assertNotEquals(shiftedAttitude.getDate(), orbit10Shifts.getDate());
    Assert.assertEquals(shiftedAttitude.getDate().durationFrom(orbit10Shifts.getDate()), 0, Precision.EPSILON);
    // action + verify no exception is thrown
    new SpacecraftState(orbit10Shifts, shiftedAttitude);
}
Also used : Orbit(org.orekit.orbits.Orbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Attitude(org.orekit.attitudes.Attitude) Test(org.junit.Test)

Example 4 with Attitude

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

the class FieldKeplerianPropagatorTest method doTestWrappedAttitudeException.

private <T extends RealFieldElement<T>> void doTestWrappedAttitudeException(Field<T> field) throws OrekitException {
    T zero = field.getZero();
    final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }

        public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }
    });
    propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAttitude(org.orekit.attitudes.FieldAttitude) Attitude(org.orekit.attitudes.Attitude) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldAttitude(org.orekit.attitudes.FieldAttitude) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) AttitudeProvider(org.orekit.attitudes.AttitudeProvider)

Example 5 with Attitude

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

the class ConstantThrustManeuver method acceleration.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D acceleration(final SpacecraftState state, final double[] parameters) throws OrekitException {
    if (firing) {
        final double thrust = parameters[0];
        final Attitude attitude = attitudeOverride == null ? state.getAttitude() : attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
        return new Vector3D(thrust / state.getMass(), attitude.getRotation().applyInverseTo(direction));
    } else {
        return Vector3D.ZERO;
    }
}
Also used : Attitude(org.orekit.attitudes.Attitude) FieldAttitude(org.orekit.attitudes.FieldAttitude) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D)

Aggregations

Attitude (org.orekit.attitudes.Attitude)11 Orbit (org.orekit.orbits.Orbit)6 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)5 SpacecraftState (org.orekit.propagation.SpacecraftState)5 AbsoluteDate (org.orekit.time.AbsoluteDate)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)4 Test (org.junit.Test)4 FieldAttitude (org.orekit.attitudes.FieldAttitude)4 OrekitException (org.orekit.errors.OrekitException)4 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)4 DummyLocalizable (org.hipparchus.exception.DummyLocalizable)2 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)2 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)2 InertialProvider (org.orekit.attitudes.InertialProvider)2 LofOffset (org.orekit.attitudes.LofOffset)2 Frame (org.orekit.frames.Frame)2 TopocentricFrame (org.orekit.frames.TopocentricFrame)2 CartesianOrbit (org.orekit.orbits.CartesianOrbit)2 DateDetector (org.orekit.propagation.events.DateDetector)2 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)2