AttitudeStateHistoryMetadata.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  2.  * Licensed to CS GROUP (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.files.ccsds.ndm.adm.acm;

  18. import org.hipparchus.geometry.euclidean.threed.RotationOrder;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.errors.OrekitMessages;
  21. import org.orekit.files.ccsds.ndm.adm.AttitudeEndpoints;
  22. import org.orekit.files.ccsds.section.CommentsContainer;

  23. /** Metadata for attitude state history.
  24.  * <p>
  25.  * Beware that the Orekit getters and setters all rely on SI units. The parsers
  26.  * and writers take care of converting these SI units into CCSDS mandatory units.
  27.  * The {@link org.orekit.utils.units.Unit Unit} class provides useful
  28.  * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
  29.  * {@link org.orekit.utils.units.Unit#toSI(double) toSI} methods in case the callers
  30.  * already use CCSDS units instead of the API SI units. The general-purpose
  31.  * {@link org.orekit.utils.units.Unit Unit} class (without an 's') and the
  32.  * CCSDS-specific {@link org.orekit.files.ccsds.definitions.Units Units} class
  33.  * (with an 's') also provide some predefined units. These predefined units and the
  34.  * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
  35.  * {@link org.orekit.utils.units.Unit#toSI(double) toSI} conversion methods are indeed
  36.  * what the parsers and writers use for the conversions.
  37.  * </p>
  38.  * @author Luc Maisonobe
  39.  * @since 12.0
  40.  */
  41. public class AttitudeStateHistoryMetadata extends CommentsContainer {

  42.     /** Endpoints (i.e. frames A, B and their relationship). */
  43.     private final AttitudeEndpoints endpoints;

  44.     /** Attitude identification number. */
  45.     private String attID;

  46.     /** Identification number of previous attitude. */
  47.     private String attPrevID;

  48.     /** Basis of this attitude state time history data. */
  49.     private String attBasis;

  50.     /** Identification number of the attitude determination or simulation upon which this attitude is based. */
  51.     private String attBasisID;

  52.     /** Rotation order for Euler angles. */
  53.     private RotationOrder eulerRotSeq;

  54.     /** Number of data states included (attitude components plus rates components). */
  55.     private int nbStates;

  56.     /** Attitude element set type. */
  57.     private AttitudeElementsType attitudeType;

  58.     /** Attitude rate element set type. */
  59.     private RateElementsType rateType;

  60.     /** Simple constructor.
  61.      */
  62.     public AttitudeStateHistoryMetadata() {
  63.         endpoints = new AttitudeEndpoints();
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public void validate(final double version) {
  68.         super.validate(version);
  69.         endpoints.checkExternalFrame(AttitudeStateHistoryMetadataKey.REF_FRAME_A,
  70.                                      AttitudeStateHistoryMetadataKey.REF_FRAME_B);
  71.         checkNotNull(attitudeType, AttitudeStateHistoryMetadataKey.ATT_TYPE.name());
  72.         final int rateSize = rateType == null ? 0 : rateType.getUnits().size();
  73.         if (nbStates != attitudeType.getUnits().size() + rateSize) {
  74.             throw new OrekitException(OrekitMessages.CCSDS_INCONSISTENT_NUMBER_OF_ATTITUDE_STATES,
  75.                                       attitudeType.toString(), rateType.toString(),
  76.                                       attitudeType.getUnits().size() + rateSize, nbStates);
  77.         }
  78.         if (attitudeType == AttitudeElementsType.EULER_ANGLES) {
  79.             checkNotNull(eulerRotSeq, AttitudeStateHistoryMetadataKey.EULER_ROT_SEQ.name());
  80.         }
  81.     }

  82.     /** Get the endpoints (i.e. frames A, B and their relationship).
  83.      * @return endpoints
  84.      */
  85.     public AttitudeEndpoints getEndpoints() {
  86.         return endpoints;
  87.     }

  88.     /** Get attitude identification number.
  89.      * @return attitude identification number
  90.      */
  91.     public String getAttID() {
  92.         return attID;
  93.     }

  94.     /** Set attitude identification number.
  95.      * @param attID attitude identification number
  96.      */
  97.     public void setAttID(final String attID) {
  98.         refuseFurtherComments();
  99.         this.attID = attID;
  100.     }

  101.     /** Get identification number of previous attitude.
  102.      * @return identification number of previous attitude
  103.      */
  104.     public String getAttPrevID() {
  105.         return attPrevID;
  106.     }

  107.     /** Set identification number of previous attitude.
  108.      * @param attPrevID identification number of previous attitude
  109.      */
  110.     public void setAttPrevID(final String attPrevID) {
  111.         refuseFurtherComments();
  112.         this.attPrevID = attPrevID;
  113.     }

  114.     /** Get basis of this attitude state time history data.
  115.      * @return basis of this attitude state time history data
  116.      */
  117.     public String getAttBasis() {
  118.         return attBasis;
  119.     }

  120.     /** Set basis of this attitude state time history data.
  121.      * @param attBasis basis of this attitude state time history data
  122.      */
  123.     public void setAttBasis(final String attBasis) {
  124.         refuseFurtherComments();
  125.         this.attBasis = attBasis;
  126.     }

  127.     /** Get identification number of the orbit determination or simulation upon which this attitude is based.
  128.      * @return identification number of the orbit determination or simulation upon which this attitude is based
  129.      */
  130.     public String getAttBasisID() {
  131.         return attBasisID;
  132.     }

  133.     /** Set identification number of the orbit determination or simulation upon which this attitude is based.
  134.      * @param attBasisID identification number of the orbit determination or simulation upon which this attitude is based
  135.      */
  136.     public void setAttBasisID(final String attBasisID) {
  137.         refuseFurtherComments();
  138.         this.attBasisID = attBasisID;
  139.     }

  140.     /** Get the rotation order for Euler angles.
  141.      * @return rotation order for Euler angles
  142.      */
  143.     public RotationOrder getEulerRotSeq() {
  144.         return eulerRotSeq;
  145.     }

  146.     /** Set the rotation order for Euler angles.
  147.      * @param eulerRotSeq rotation order for Euler angles
  148.      */
  149.     public void setEulerRotSeq(final RotationOrder eulerRotSeq) {
  150.         this.eulerRotSeq = eulerRotSeq;
  151.     }

  152.     /** Get the number of data states included (attitude components plus rates components).
  153.      * @return number of data states included (attitude components plus rates components)
  154.      */
  155.     public int getNbStates() {
  156.         return nbStates;
  157.     }

  158.     /** Set the number of data states included (attitude components plus rates components).
  159.      * @param nbStates number of data states included (attitude components plus rates components)
  160.      */
  161.     public void setNbStates(final int nbStates) {
  162.         this.nbStates = nbStates;
  163.     }

  164.     /** Get attitude element set type.
  165.      * @return attitude element set type
  166.      */
  167.     public AttitudeElementsType getAttitudeType() {
  168.         return attitudeType;
  169.     }

  170.     /** Set attitude element set type.
  171.      * @param attitudeType attitude element set type
  172.      */
  173.     public void setAttitudeType(final AttitudeElementsType attitudeType) {
  174.         refuseFurtherComments();
  175.         this.attitudeType = attitudeType;
  176.     }

  177.     /** Get attitude rate element set type.
  178.      * @return attitude rate element set type
  179.      */
  180.     public RateElementsType getRateType() {
  181.         return rateType;
  182.     }

  183.     /** Set attitude rate element set type.
  184.      * @param rateType attitude rate element set type
  185.      */
  186.     public void setRateType(final RateElementsType rateType) {
  187.         refuseFurtherComments();
  188.         this.rateType = rateType;
  189.     }

  190. }