AttitudesSequence.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.attitudes;

  18. import java.util.ArrayList;
  19. import java.util.Arrays;
  20. import java.util.List;
  21. import java.util.Map;

  22. import org.hipparchus.Field;
  23. import org.hipparchus.RealFieldElement;
  24. import org.orekit.errors.OrekitException;
  25. import org.orekit.errors.OrekitMessages;
  26. import org.orekit.frames.Frame;
  27. import org.orekit.orbits.Orbit;
  28. import org.orekit.propagation.FieldPropagator;
  29. import org.orekit.propagation.FieldSpacecraftState;
  30. import org.orekit.propagation.Propagator;
  31. import org.orekit.propagation.SpacecraftState;
  32. import org.orekit.propagation.events.EventDetector;
  33. import org.orekit.propagation.events.FieldEventDetector;
  34. import org.orekit.propagation.events.handlers.EventHandler.Action;
  35. import org.orekit.propagation.events.handlers.FieldEventHandler;
  36. import org.orekit.time.AbsoluteDate;
  37. import org.orekit.time.FieldAbsoluteDate;
  38. import org.orekit.utils.AngularDerivativesFilter;
  39. import org.orekit.utils.FieldPVCoordinatesProvider;
  40. import org.orekit.utils.PVCoordinatesProvider;
  41. import org.orekit.utils.TimeSpanMap;
  42. import org.orekit.utils.TimeStampedAngularCoordinates;
  43. import org.orekit.utils.TimeStampedFieldAngularCoordinates;

  44. /** This classes manages a sequence of different attitude providers that are activated
  45.  * in turn according to switching events.
  46.  * <p>Only one attitude provider in the sequence is in an active state. When one of
  47.  * the switch event associated with the active provider occurs, the active provider becomes
  48.  * the one specified with the event. A simple example is a provider for the sun lighted part
  49.  * of the orbit and another provider for the eclipse time. When the sun lighted provider is active,
  50.  * the eclipse entry event is checked and when it occurs the eclipse provider is activated.
  51.  * When the eclipse provider is active, the eclipse exit event is checked and when it occurs
  52.  * the sun lighted provider is activated again. This sequence is a simple loop.</p>
  53.  * <p>An active attitude provider may have several switch events and next provider settings, leading
  54.  * to different activation patterns depending on which events are triggered first. An example
  55.  * of this feature is handling switches to safe mode if some contingency condition is met, in
  56.  * addition to the nominal switches that correspond to proper operations. Another example
  57.  * is handling of maneuver mode.<p>
  58.  * <p>
  59.  * Note that this attitude provider is stateful, it keeps in memory the sequence of active
  60.  * underlying providers with their switch dates and the transitions from one provider to
  61.  * the other. This implies that this provider should <em>not</em> be shared among different
  62.  * propagators at the same time, each propagator should use its own instance of this provider.
  63.  * </p>
  64.  * <p>
  65.  * The sequence kept in memory is reset when {@link #resetActiveProvider(AttitudeProvider)}
  66.  * is called, and only the specify provider is kept. The sequence is also partially
  67.  * reset each time a propagation starts. If a new propagation is started after a first
  68.  * propagation has been run, all the already computed switches that occur after propagation
  69.  * start for forward propagation or before propagation start for backward propagation will
  70.  * be erased. New switches will be computed and applied properly according to the new
  71.  * propagation settings. The already computed switches that are not in covered are kept
  72.  * in memory. This implies that if a propagation is interrupted and restarted in the
  73.  * same direction, then attitude switches will remain in place, ensuring that even if the
  74.  * interruption occurred in the middle of an attitude transition the second propagation will
  75.  * properly complete the transition that was started by the first propagator.
  76.  * </p>
  77.  * @author Luc Maisonobe
  78.  * @since 5.1
  79.  */
  80. public class AttitudesSequence implements AttitudeProvider {

  81.     /** Serializable UID. */
  82.     private static final long serialVersionUID = 20180326L;

  83.     /** Providers that have been activated. */
  84.     private TimeSpanMap<AttitudeProvider> activated;

  85.     /** Switching events list. */
  86.     private final List<Switch<?>> switches;

  87.     /** Constructor for an initially empty sequence.
  88.      */
  89.     public AttitudesSequence() {
  90.         activated = null;
  91.         switches  = new ArrayList<Switch<?>>();
  92.     }

  93.     /** Reset the active provider.
  94.      * <p>
  95.      * Calling this method clears all already seen switch history,
  96.      * so it should <em>not</em> be used during the propagation itself,
  97.      * it is intended to be used only at start
  98.      * </p>
  99.      * @param provider provider to activate
  100.      */
  101.     public void resetActiveProvider(final AttitudeProvider provider) {
  102.         activated = new TimeSpanMap<AttitudeProvider>(provider);
  103.     }

  104.     /** Register all wrapped switch events to the propagator.
  105.      * <p>
  106.      * This method must be called once before propagation, after the
  107.      * switching conditions have been set up by calls to {@link
  108.      * #addSwitchingCondition(AttitudeProvider, AttitudeProvider, EventDetector,
  109.      * boolean, boolean, double, AngularDerivativesFilter, SwitchHandler)
  110.      * addSwitchingCondition}.
  111.      * </p>
  112.      * @param propagator propagator that will handle the events
  113.      */
  114.     public void registerSwitchEvents(final Propagator propagator) {
  115.         for (final Switch<?> s : switches) {
  116.             propagator.addEventDetector(s);
  117.         }
  118.     }

  119.     /** Register all wrapped switch events to the propagator.
  120.      * <p>
  121.      * This method must be called once before propagation, after the
  122.      * switching conditions have been set up by calls to {@link
  123.      * #addSwitchingCondition(AttitudeProvider, AttitudeProvider, EventDetector,
  124.      * boolean, boolean, double, AngularDerivativesFilter, SwitchHandler)
  125.      * addSwitchingCondition}.
  126.      * </p>
  127.      * @param field field to which the elements belong
  128.      * @param propagator propagator that will handle the events
  129.      * @param <T> type of the field elements
  130.      */
  131.     public <T extends RealFieldElement<T>> void registerSwitchEvents(final Field<T> field, final FieldPropagator<T> propagator) {
  132.         for (final Switch<?> sw : switches) {
  133.             propagator.addEventDetector(new FieldEventDetector<T>() {

  134.                 /** {@inheritDoc} */
  135.                 @Override
  136.                 public void init(final FieldSpacecraftState<T> s0,
  137.                                  final FieldAbsoluteDate<T> t) {
  138.                     sw.init(s0.toSpacecraftState(), t.toAbsoluteDate());
  139.                 }

  140.                 /** {@inheritDoc} */
  141.                 @Override
  142.                 public T g(final FieldSpacecraftState<T> s) {
  143.                     return field.getZero().add(sw.g(s.toSpacecraftState()));
  144.                 }

  145.                 /** {@inheritDoc} */
  146.                 @Override
  147.                 public T getThreshold() {
  148.                     return field.getZero().add(sw.getThreshold());
  149.                 }

  150.                 /** {@inheritDoc} */
  151.                 @Override
  152.                 public T getMaxCheckInterval() {
  153.                     return field.getZero().add(sw.getMaxCheckInterval());
  154.                 }

  155.                 /** {@inheritDoc} */
  156.                 @Override
  157.                 public int getMaxIterationCount() {
  158.                     return sw.getMaxIterationCount();
  159.                 }

  160.                 /** {@inheritDoc} */
  161.                 @Override
  162.                 public FieldEventHandler.Action eventOccurred(final FieldSpacecraftState<T> s, final boolean increasing) {
  163.                     switch(sw.eventOccurred(s.toSpacecraftState(), increasing)) {
  164.                         case STOP :
  165.                             return FieldEventHandler.Action.STOP;
  166.                         case RESET_DERIVATIVES :
  167.                             return FieldEventHandler.Action.RESET_DERIVATIVES;
  168.                         case RESET_STATE :
  169.                             return FieldEventHandler.Action.RESET_STATE;
  170.                         default :
  171.                             return FieldEventHandler.Action.CONTINUE;
  172.                     }
  173.                 }

  174.                 /** {@inheritDoc} */
  175.                 @Override
  176.                 public FieldSpacecraftState<T> resetState(final FieldSpacecraftState<T> oldState) {
  177.                     return new FieldSpacecraftState<>(field, sw.resetState(oldState.toSpacecraftState()));
  178.                 }

  179.             });
  180.         }
  181.     }

  182.     /** Add a switching condition between two attitude providers.
  183.      * <p>
  184.      * The {@code past} and {@code future} attitude providers are defined with regard
  185.      * to the natural flow of time. This means that if the propagation is forward, the
  186.      * propagator will switch from {@code past} provider to {@code future} provider at
  187.      * event occurrence, but if the propagation is backward, the propagator will switch
  188.      * from {@code future} provider to {@code past} provider at event occurrence. The
  189.      * transition between the two attitude laws is not instantaneous, the switch event
  190.      * defines the start of the transition (i.e. when leaving the {@code past} attitude
  191.      * law and entering the interpolated transition law). The end of the transition
  192.      * (i.e. when leaving the interpolating transition law and entering the {@code future}
  193.      * attitude law) occurs at switch time plus {@code transitionTime}.
  194.      * </p>
  195.      * <p>
  196.      * An attitude provider may have several different switch events associated to
  197.      * it. Depending on which event is triggered, the appropriate provider is
  198.      * switched to.
  199.      * </p>
  200.      * <p>
  201.      * The switch events specified here must <em>not</em> be registered to the
  202.      * propagator directly. The proper way to register these events is to
  203.      * call {@link #registerSwitchEvents(Propagator)} once after all switching
  204.      * conditions have been set up. The reason for this is that the events will
  205.      * be wrapped before being registered.
  206.      * </p>
  207.      * <p>
  208.      * If the underlying detector has an event handler associated to it, this handler
  209.      * will be triggered (i.e. its {@link org.orekit.propagation.events.handlers.EventHandler#eventOccurred(SpacecraftState,
  210.      * EventDetector, boolean) eventOccurred} method will be called), <em>regardless</em>
  211.      * of the event really triggering an attitude switch or not. As an example, if an
  212.      * eclipse detector is used to switch from day to night attitude mode when entering
  213.      * eclipse, with {@code switchOnIncrease} set to {@code false} and {@code switchOnDecrease}
  214.      * set to {@code true}. Then a handler set directly at eclipse detector level would
  215.      * be triggered at both eclipse entry and eclipse exit, but attitude switch would
  216.      * occur <em>only</em> at eclipse entry. Note that for the sake of symmetry, the
  217.      * transition start and end dates should match for both forward and backward propagation.
  218.      * This implies that for backward propagation, we have to compensate for the {@code
  219.      * transitionTime} when looking for the event. An unfortunate consequence is that the
  220.      * {@link org.orekit.propagation.events.handlers.EventHandler#eventOccurred(SpacecraftState, EventDetector, boolean)
  221.      * eventOccurred} method may appear to be called out of sync with respect to the
  222.      * propagation (it will be called when propagator reaches transition end, despite it
  223.      * refers to transition start, as per {@code transitionTime} compensation), and if the
  224.      * method returns {@link Action#STOP}, it will stop at the end of the
  225.      * transition instead of at the start. For these reasons, it is not recommended to
  226.      * set up an event handler for events that are used to switch attitude. If an event
  227.      * handler is needed for other purposes, a second handler should be registered to
  228.      * the propagator rather than relying on the side effects of attitude switches.
  229.      * </p>
  230.      * <p>
  231.      * The smoothness of the transition between past and future attitude laws can be tuned
  232.      * using the {@code transitionTime} and {@code transitionFilter} parameters. The {@code
  233.      * transitionTime} parameter specifies how much time is spent to switch from one law to
  234.      * the other law. It should be larger than the event {@link EventDetector#getThreshold()
  235.      * convergence threshold} in order to ensure attitude continuity. The {@code
  236.      * transitionFilter} parameter specifies the attitude time derivatives that should match
  237.      * at the boundaries between past attitude law and transition law on one side, and
  238.      * between transition law and future law on the other side.
  239.      * {@link AngularDerivativesFilter#USE_R} means only the rotation should be identical,
  240.      * {@link AngularDerivativesFilter#USE_RR} means both rotation and rotation rate
  241.      * should be identical, {@link AngularDerivativesFilter#USE_RRA} means both rotation,
  242.      * rotation rate and rotation acceleration should be identical. During the transition,
  243.      * the attitude law is computed by interpolating between past attitude law at switch time
  244.      * and future attitude law at current intermediate time.
  245.      * </p>
  246.      * @param past attitude provider applicable for times in the switch event occurrence past
  247.      * @param future attitude provider applicable for times in the switch event occurrence future
  248.      * @param switchEvent event triggering the attitude providers switch
  249.      * @param switchOnIncrease if true, switch is triggered on increasing event
  250.      * @param switchOnDecrease if true, switch is triggered on decreasing event
  251.      * @param transitionTime duration of the transition between the past and future attitude laws
  252.      * @param transitionFilter specification of transition law time derivatives that
  253.      * should match past and future attitude laws
  254.      * @param handler handler to call for notifying when switch occurs (may be null)
  255.      * @param <T> class type for the switch event
  256.      * @since 7.1
  257.      */
  258.     public <T extends EventDetector> void addSwitchingCondition(final AttitudeProvider past,
  259.                                                                 final AttitudeProvider future,
  260.                                                                 final T switchEvent,
  261.                                                                 final boolean switchOnIncrease,
  262.                                                                 final boolean switchOnDecrease,
  263.                                                                 final double transitionTime,
  264.                                                                 final AngularDerivativesFilter transitionFilter,
  265.                                                                 final SwitchHandler handler) {

  266.         // safety check, for ensuring attitude continuity
  267.         if (transitionTime < switchEvent.getThreshold()) {
  268.             throw new OrekitException(OrekitMessages.TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH,
  269.                                       transitionTime, switchEvent.getThreshold());
  270.         }

  271.         // if it is the first switching condition, assume first active law is the past one
  272.         if (activated == null) {
  273.             resetActiveProvider(past);
  274.         }

  275.         // add the switching condition
  276.         switches.add(new Switch<T>(switchEvent, switchOnIncrease, switchOnDecrease,
  277.                                    past, future, transitionTime, transitionFilter, handler));

  278.     }

  279.     /** {@inheritDoc} */
  280.     public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  281.                                 final AbsoluteDate date, final Frame frame) {
  282.         return activated.get(date).getAttitude(pvProv, date, frame);
  283.     }

  284.     /** {@inheritDoc} */
  285.     public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
  286.                                                                         final FieldAbsoluteDate<T> date,
  287.                                                                         final Frame frame) {
  288.         return activated.get(date.toAbsoluteDate()).getAttitude(pvProv, date, frame);
  289.     }

  290.     /** Switch specification.
  291.      * @param <T> class type for the generic version
  292.      */
  293.     private class Switch<T extends EventDetector> implements EventDetector {

  294.         /** Serializable UID. */
  295.         private static final long serialVersionUID = 20150604L;

  296.         /** Event. */
  297.         private final T event;

  298.         /** Event direction triggering the switch. */
  299.         private final boolean switchOnIncrease;

  300.         /** Event direction triggering the switch. */
  301.         private final boolean switchOnDecrease;

  302.         /** Attitude provider applicable for times in the switch event occurrence past. */
  303.         private final AttitudeProvider past;

  304.         /** Attitude provider applicable for times in the switch event occurrence future. */
  305.         private final AttitudeProvider future;

  306.         /** Duration of the transition between the past and future attitude laws. */
  307.         private final double transitionTime;

  308.         /** Order at which the transition law time derivatives should match past and future attitude laws. */
  309.         private final AngularDerivativesFilter transitionFilter;

  310.         /** Handler to call for notifying when switch occurs (may be null). */
  311.         private final SwitchHandler switchHandler;

  312.         /** Propagation direction. */
  313.         private boolean forward;

  314.         /** Simple constructor.
  315.          * @param event event
  316.          * @param switchOnIncrease if true, switch is triggered on increasing event
  317.          * @param switchOnDecrease if true, switch is triggered on decreasing event
  318.          * otherwise switch is triggered on decreasing event
  319.          * @param past attitude provider applicable for times in the switch event occurrence past
  320.          * @param future attitude provider applicable for times in the switch event occurrence future
  321.          * @param transitionTime duration of the transition between the past and future attitude laws
  322.          * @param transitionFilter order at which the transition law time derivatives
  323.          * should match past and future attitude laws
  324.          * @param switchHandler handler to call for notifying when switch occurs (may be null)
  325.          */
  326.         Switch(final T event,
  327.                final boolean switchOnIncrease, final boolean switchOnDecrease,
  328.                final AttitudeProvider past, final AttitudeProvider future,
  329.                final double transitionTime, final AngularDerivativesFilter transitionFilter,
  330.                final SwitchHandler switchHandler) {
  331.             this.event            = event;
  332.             this.switchOnIncrease = switchOnIncrease;
  333.             this.switchOnDecrease = switchOnDecrease;
  334.             this.past             = past;
  335.             this.future           = future;
  336.             this.transitionTime   = transitionTime;
  337.             this.transitionFilter = transitionFilter;
  338.             this.switchHandler    = switchHandler;
  339.         }

  340.         /** {@inheritDoc} */
  341.         @Override
  342.         public double getThreshold() {
  343.             return event.getThreshold();
  344.         }

  345.         /** {@inheritDoc} */
  346.         @Override
  347.         public double getMaxCheckInterval() {
  348.             return event.getMaxCheckInterval();
  349.         }

  350.         /** {@inheritDoc} */
  351.         @Override
  352.         public int getMaxIterationCount() {
  353.             return event.getMaxIterationCount();
  354.         }

  355.         /** {@inheritDoc} */
  356.         public void init(final SpacecraftState s0,
  357.                          final AbsoluteDate t) {

  358.             // reset the transition parameters (this will be done once for each switch,
  359.             //  despite doing it only once would have sufficient; its not really a problem)
  360.             forward = t.durationFrom(s0.getDate()) >= 0.0;
  361.             if (activated.getTransitions().size() > 1) {
  362.                 // remove transitions that will be overridden during upcoming propagation
  363.                 if (forward) {
  364.                     activated = activated.extractRange(AbsoluteDate.PAST_INFINITY, s0.getDate());
  365.                 } else {
  366.                     activated = activated.extractRange(s0.getDate(), AbsoluteDate.FUTURE_INFINITY);
  367.                 }
  368.             }

  369.             // initialize the underlying event
  370.             event.init(s0, t);

  371.         }

  372.         /** {@inheritDoc} */
  373.         public double g(final SpacecraftState s) {
  374.             return event.g(forward ? s : s.shiftedBy(-transitionTime));
  375.         }

  376.         /** {@inheritDoc} */
  377.         public Action eventOccurred(final SpacecraftState s, final boolean increasing) {

  378.             final AbsoluteDate date = s.getDate();
  379.             if (activated.get(date) == (forward ? past : future) &&
  380.                 ((increasing && switchOnIncrease) || (!increasing && switchOnDecrease))) {

  381.                 if (forward) {

  382.                     // prepare transition
  383.                     final AbsoluteDate transitionEnd = date.shiftedBy(transitionTime);
  384.                     activated.addValidAfter(new TransitionProvider(s.getAttitude(), transitionEnd), date);

  385.                     // prepare future law after transition
  386.                     activated.addValidAfter(future, transitionEnd);

  387.                     // notify about the switch
  388.                     if (switchHandler != null) {
  389.                         switchHandler.switchOccurred(past, future, s);
  390.                     }

  391.                     return event.eventOccurred(s, increasing);

  392.                 } else {

  393.                     // estimate state at transition start, according to the past attitude law
  394.                     final Orbit     sOrbit    = s.getOrbit().shiftedBy(-transitionTime);
  395.                     final Attitude  sAttitude = past.getAttitude(sOrbit, sOrbit.getDate(), sOrbit.getFrame());
  396.                     SpacecraftState sState    = new SpacecraftState(sOrbit, sAttitude, s.getMass());
  397.                     for (final Map.Entry<String, double[]> entry : s.getAdditionalStates().entrySet()) {
  398.                         sState = sState.addAdditionalState(entry.getKey(), entry.getValue());
  399.                     }

  400.                     // prepare transition
  401.                     activated.addValidBefore(new TransitionProvider(sAttitude, date), date);

  402.                     // prepare past law before transition
  403.                     activated.addValidBefore(past, sOrbit.getDate());

  404.                     // notify about the switch
  405.                     if (switchHandler != null) {
  406.                         switchHandler.switchOccurred(future, past, sState);
  407.                     }

  408.                     return event.eventOccurred(sState, increasing);

  409.                 }

  410.             } else {
  411.                 // trigger the underlying event despite no attitude switch occurred
  412.                 return event.eventOccurred(s, increasing);
  413.             }

  414.         }

  415.         /** {@inheritDoc} */
  416.         @Override
  417.         public SpacecraftState resetState(final SpacecraftState oldState) {
  418.             // delegate to underlying event
  419.             return event.resetState(oldState);
  420.         }

  421.         /** Provider for transition phases.
  422.          * @since 9.2
  423.          */
  424.         private class TransitionProvider implements AttitudeProvider {

  425.             /** Serializable UID. */
  426.             private static final long serialVersionUID = 20180326L;

  427.             /** Attitude at preceding transition. */
  428.             private final Attitude transitionPreceding;

  429.             /** Date of final switch to following attitude law. */
  430.             private final AbsoluteDate transitionEnd;

  431.             /** Simple constructor.
  432.              * @param transitionPreceding attitude at preceding transition
  433.              * @param transitionEnd date of final switch to following attitude law
  434.              */
  435.             TransitionProvider(final Attitude transitionPreceding, final AbsoluteDate transitionEnd) {
  436.                 this.transitionPreceding = transitionPreceding;
  437.                 this.transitionEnd       = transitionEnd;
  438.             }

  439.             /** {@inheritDoc} */
  440.             public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  441.                                         final AbsoluteDate date, final Frame frame) {

  442.                 // interpolate between the two boundary attitudes
  443.                 final TimeStampedAngularCoordinates start =
  444.                                 transitionPreceding.withReferenceFrame(frame).getOrientation();
  445.                 final TimeStampedAngularCoordinates end =
  446.                                 future.getAttitude(pvProv, transitionEnd, frame).getOrientation();
  447.                 final TimeStampedAngularCoordinates interpolated =
  448.                                 TimeStampedAngularCoordinates.interpolate(date, transitionFilter,
  449.                                                                           Arrays.asList(start, end));

  450.                 return new Attitude(frame, interpolated);

  451.             }

  452.             /** {@inheritDoc} */
  453.             public <S extends RealFieldElement<S>> FieldAttitude<S> getAttitude(final FieldPVCoordinatesProvider<S> pvProv,
  454.                                                                                 final FieldAbsoluteDate<S> date,
  455.                                                                                 final Frame frame) {

  456.                 // interpolate between the two boundary attitudes
  457.                 final TimeStampedFieldAngularCoordinates<S> start =
  458.                                 new TimeStampedFieldAngularCoordinates<>(date.getField(),
  459.                                                                          transitionPreceding.withReferenceFrame(frame).getOrientation());
  460.                 final TimeStampedFieldAngularCoordinates<S> end =
  461.                                 future.getAttitude(pvProv,
  462.                                                    new FieldAbsoluteDate<>(date.getField(), transitionEnd),
  463.                                                    frame).getOrientation();
  464.                 final TimeStampedFieldAngularCoordinates<S> interpolated =
  465.                                 TimeStampedFieldAngularCoordinates.interpolate(date, transitionFilter,
  466.                                                                                Arrays.asList(start, end));

  467.                 return new FieldAttitude<>(frame, interpolated);
  468.             }

  469.         }

  470.     }

  471.     /** Interface for attitude switch notifications.
  472.      * <p>
  473.      * This interface is intended to be implemented by users who want to be
  474.      * notified when an attitude switch occurs.
  475.      * </p>
  476.      * @since 7.1
  477.      */
  478.     public interface SwitchHandler {

  479.         /** Method called when attitude is switched from one law to another law.
  480.          * @param preceding attitude law used preceding the switch (i.e. in the past
  481.          * of the switch event for a forward propagation, or in the future
  482.          * of the switch event for a backward propagation)
  483.          * @param following attitude law used following the switch (i.e. in the future
  484.          * of the switch event for a forward propagation, or in the past
  485.          * of the switch event for a backward propagation)
  486.          * @param state state at switch time (with attitude computed using the {@code preceding} law)
  487.          */
  488.         void switchOccurred(AttitudeProvider preceding, AttitudeProvider following, SpacecraftState state);

  489.     }

  490. }