SpacecraftBodyFrame.java

  1. /* Copyright 2002-2022 CS GROUP
  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.definitions;

  18. import org.orekit.errors.OrekitException;
  19. import org.orekit.errors.OrekitMessages;

  20. /** Frames used in CCSDS Attitude Data Messages for the spacecraft body.
  21.  * @author Luc Maisonobe
  22.  * @since 11.0
  23.  */
  24. public class SpacecraftBodyFrame {

  25.     /** Equipment on which the frame is located. */
  26.     public enum BaseEquipment {

  27.         /** Accelerometer. */
  28.         ACC,

  29.         /** Actuator: could denote reaction wheels, solar arrays, thrusters, etc.. */
  30.         ACTUATOR,

  31.         /** Autonomous Star Tracker. */
  32.         AST,

  33.         /** Coarse Sun Sensor. */
  34.         CSS,

  35.         /** Digital Sun Sensor. */
  36.         DSS,

  37.         /** Earth Sensor Assembly. */
  38.         ESA,

  39.         /** Gyro reference frame (this name was used in ADM V1.0 (CCSDS 504.0-B-1). */
  40.         GYRO,

  41.         /** Gyro reference frame (this name is used in SANA registry https://sanaregistry.org/r/spacecraft_body_reference_frames/). */
  42.         GYRO_FRAME,

  43.         /** Inertial Measurement Unit. */
  44.         IMU_FRAME,

  45.         /** Instrument. */
  46.         INSTRUMENT,

  47.         /** Magnetic Torque Assembly. */
  48.         MTA,

  49.         /** Reaction Wheel. */
  50.         RW,

  51.         /** Solar Array. */
  52.         SA,

  53.         /** Spacecraft Body. */
  54.         SC_BODY,

  55.         /** Sensor. */
  56.         SENSOR,

  57.         /** Star Tracker. */
  58.         STARTRACKER,

  59.         /** Three Axis Magnetometer. */
  60.         TAM;

  61.     }

  62.     /** Equipment on which the frame is located. */
  63.     private final BaseEquipment baseEquipment;

  64.     /** Frame label. */
  65.     private final String label;

  66.     /** Simple constructor.
  67.      * @param baseEquipment equipment on which the frame is located
  68.      * @param label frame label
  69.      */
  70.     public SpacecraftBodyFrame(final BaseEquipment baseEquipment, final String label) {
  71.         this.baseEquipment = baseEquipment;
  72.         this.label         = label;
  73.     }

  74.     /** Get the quipment on which the frame is located.
  75.      * @return equipment on which the frame is located
  76.      */
  77.     public BaseEquipment getBaseEquipment() {
  78.         return baseEquipment;
  79.     }

  80.     /** Get the frame label.
  81.      * @return frame label
  82.      */
  83.     public String getLabel() {
  84.         return label;
  85.     }

  86.     /** {@inheritDoc}
  87.      * <p>
  88.      * The CCSDS composite name combines the {@link #getBaseEquipment() base equipment}
  89.      * and the {@link #getLabel()}
  90.      * </p>
  91.      * @return CCSDS composite name
  92.      */
  93.     @Override
  94.     public String toString() {
  95.         return getBaseEquipment().name() + "_" + getLabel();
  96.     }

  97.     /** Build an instance from a normalized descriptor.
  98.      * <p>
  99.      * Normalized strings have '_' characters replaced by spaces,
  100.      * and multiple spaces collapsed as one space only.
  101.      * </p>
  102.      * @param descriptor normalized descriptor
  103.      * @return parsed body frame
  104.      */
  105.     public static SpacecraftBodyFrame parse(final String descriptor) {
  106.         final int separatorIndex = descriptor.lastIndexOf('_');
  107.         if (separatorIndex >= 0) {
  108.             try {
  109.                 final String equipmentName = descriptor.substring(0, separatorIndex);
  110.                 return new SpacecraftBodyFrame(BaseEquipment.valueOf(equipmentName),
  111.                                           descriptor.substring(separatorIndex + 1));
  112.             } catch (IllegalArgumentException iae) {
  113.                 // ignored, errors are handled below
  114.             }
  115.         }
  116.         throw new OrekitException(OrekitMessages.CCSDS_INVALID_FRAME, descriptor);
  117.     }

  118. }