GroundPointingWrapper.java

  1. /* Copyright 2002-2013 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 org.apache.commons.math3.geometry.euclidean.threed.Rotation;
  19. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.AngularCoordinates;
  24. import org.orekit.utils.PVCoordinates;
  25. import org.orekit.utils.PVCoordinatesProvider;


  26. /** This class leverages common parts for compensation modes around ground pointing attitudes.
  27.  * @author Véronique Pommier-Maurussane
  28.  * @author Luc Maisonobe
  29.  */
  30. public abstract class GroundPointingWrapper extends GroundPointing implements AttitudeProviderModifier {

  31.     /** Serializable UID. */
  32.     private static final long serialVersionUID = 262999520075931766L;

  33.     /** Underlying ground pointing attitude provider.  */
  34.     private final GroundPointing groundPointingLaw;

  35.     /** Creates a new instance.
  36.      * @param groundPointingLaw ground pointing attitude provider without compensation
  37.      */
  38.     public GroundPointingWrapper(final GroundPointing groundPointingLaw) {
  39.         super(groundPointingLaw.getBodyFrame());
  40.         this.groundPointingLaw = groundPointingLaw;
  41.     }

  42.     /** Get the underlying ground pointing law.
  43.      * @return underlying ground pointing law.
  44.      * @see #getUnderlyingAttitudeProvider()
  45.      * @deprecated as of 6.0, replaced by {@link #getUnderlyingAttitudeProvider()}
  46.      */
  47.     @Deprecated
  48.     public GroundPointing getGroundPointingLaw() {
  49.         return groundPointingLaw;
  50.     }

  51.     /** Get the underlying (ground pointing) attitude provider.
  52.      * @return underlying attitude provider, which in this case is a {@link GroundPointing} instance
  53.      */
  54.     public AttitudeProvider getUnderlyingAttitudeProvider() {
  55.         return groundPointingLaw;
  56.     }

  57.     /** {@inheritDoc} */
  58.     protected Vector3D getTargetPoint(final PVCoordinatesProvider pvProv,
  59.                                       final AbsoluteDate date, final Frame frame)
  60.         throws OrekitException {
  61.         return groundPointingLaw.getTargetPoint(pvProv, date, frame);
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     protected PVCoordinates getTargetPV(final PVCoordinatesProvider pvProv,
  66.                                         final AbsoluteDate date, final Frame frame)
  67.         throws OrekitException {
  68.         return groundPointingLaw.getTargetPV(pvProv, date, frame);
  69.     }

  70.     /** Compute the base system state at given date, without compensation.
  71.      * @param pvProv provider for PV coordinates
  72.      * @param date date at which state is requested
  73.      * @param frame reference frame from which attitude is computed
  74.      * @return satellite base attitude state, i.e without compensation.
  75.      * @throws OrekitException if some specific error occurs
  76.      */
  77.     public Attitude getBaseState(final PVCoordinatesProvider pvProv,
  78.                                  final AbsoluteDate date, final Frame frame)
  79.         throws OrekitException {
  80.         return groundPointingLaw.getAttitude(pvProv, date, frame);
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  85.                                 final AbsoluteDate date, final Frame frame)
  86.         throws OrekitException {

  87.         // Get attitude from base attitude provider
  88.         final Attitude base = getBaseState(pvProv, date, frame);

  89.         // Get compensation
  90.         final Rotation compensation = getCompensation(pvProv, date, frame, base);

  91.         // Compute compensation rotation rate
  92.         final double h = 0.1;
  93.         final Rotation compensationM1H  = getCompensation(pvProv, date.shiftedBy(-h), frame, base.shiftedBy(-h));
  94.         final Rotation compensationP1H  = getCompensation(pvProv, date.shiftedBy( h), frame, base.shiftedBy( h));
  95.         final Vector3D compensationRate = AngularCoordinates.estimateRate(compensationM1H, compensationP1H, 2 * h);

  96.         // Combination of base attitude, compensation and compensation rate
  97.         return new Attitude(date, frame,
  98.                             compensation.applyTo(base.getRotation()),
  99.                             compensationRate.add(compensation.applyTo(base.getSpin())));

  100.     }

  101.     /** Compute the compensation rotation at given date.
  102.      * @param pvProv provider for PV coordinates
  103.      * @param date date at which rotation is requested
  104.      * @param frame reference frame from which attitude is computed
  105.      * @param base base satellite attitude in given frame.
  106.      * @return compensation rotation at date, i.e rotation between non compensated
  107.      * attitude state and compensated state.
  108.      * @throws OrekitException if some specific error occurs
  109.      */
  110.     public abstract Rotation getCompensation(final PVCoordinatesProvider pvProv,
  111.                                              final AbsoluteDate date, final Frame frame,
  112.                                              final Attitude base)
  113.         throws OrekitException;

  114. }