WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
GroundStationModel.h
/******************************************************************************
* Copyright (c) ATTX INC 2025. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the 
* proprietary and confidential information of ATTX INC. The Software is 
* furnished under a license agreement between ATTX and the user organization 
* and may be used or copied only in accordance with the terms of the agreement.
* Refer to 'license/attx_license.adoc' for standard license terms.
*
* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION 
* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or 
* transmitted in any form or by any means, for any purpose, without the express 
* written permission of ATTX INC.
******************************************************************************/
/*
Ground station model header file

Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Ground Station",
          "exclude" : False,
          "category" : "Assemblies"
}
aliases = {"spacecraft_frame" : "Spacecraft Body",
           "planet_rotating_frame" : "Planet Rotating Frame",
           "R_planet" : "Planet Equatorial Radius",
           "flattening_planet" : "Ellipse Flattening",
           "latitude_detic_rad" : "Latitude",
           "longitude_rad" : "Longitude",
           "elevation_mask_rad" : "Elevation Mask",
           "position__enu" : "EXCLUDE",
           "velocity__enu" : "EXCLUDE",
           "range" : "Range",
           "range_rate" : "Range Rate",
           "azimuth" : "Azimuth",
           "elevation" : "Elevation",
           "masked" : "Masked",
           "gs_position__pci" : "EXCLUDE",
           "gs_velocity__pci" : "EXCLUDE",
           "self_ptr" : "Ground Station"
}
*/

#ifndef MODELS_STATES_GROUND_STATION_MODEL_H
#define MODELS_STATES_GROUND_STATION_MODEL_H

#include "FrameStateSensorModel.h"
#include "RangeAzElSensorModel.h"
#include "constants/planetdefaults.h"

namespace warptwin {

    /**
     * @brief   Simple ground station model
     * 
     * This model is a simple model of a ground station. It uses the FrameStateSensor
     * and RangeAzElSensor internally to create an ENU frame as a child of the parent
     * frame, then returns results every step. It is primarily a configuration wrapper
     * model -- that is, it does the large majority of its work in startup, and adds
     * little to no functionality at runtime, and instead runs the innter frame state
     * sensor and range az el sensor model, which do the heavy lifting.
    */
    MODEL(GroundStationModel)
    public:
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** The frame of the spacecraft object that the ground station will sense*/
            SIGNAL(spacecraft_frame,        Frame*,                nullptr)
            /** The planet rotating frame to which the ground station is attached. Note that
             *  the planet rotating frame must be a child of the associated planet inertial
             *  frame, which is also used in this model. */
            SIGNAL(planet_rotating_frame,   Frame*,                nullptr)
            /** This is the equatorial radius of the planet. Default is Earth in meters */
            SIGNAL(R_planet,                double,                 warpos::earth_wgs84.eq_radius)
            /** This is the flattening of the planet, which defines shape. Default is Earth */
            SIGNAL(flattening_planet,       double,                 warpos::earth_wgs84.flattening)
            /** This is the centric latitude of the ground station, in radians */
            SIGNAL(latitude_detic_rad,      double,                 0.0)
            /** The longitude of the ground station, in radians*/
            SIGNAL(longitude_rad,           double,                 0.0)
            /** This is the elevation mask value, in radians, for the ground station. Default is zero degrees*/
            SIGNAL(elevation_mask_rad,      double,                 0.0)
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS

        END_INPUTS

        // Model outputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_OUTPUTS
            /** The position of the spacecraft as measured in the GS East, North, Up frame */
            SIGNAL(position__enu,           CartesianVector3,      CartesianVector3())
            /** The velocity of the spacecraft as measured in the GS East, North, Up frame*/
            SIGNAL(velocity__enu,           CartesianVector3,      CartesianVector3())
            /** This is the range of the input object to the frame. Will be zero if masked.*/
            SIGNAL(range,                   double,                 0.0)
            /** This is the range rate of the spacecraft to the GS. Will be zero if masked.*/
            SIGNAL(range_rate,              double,                 0.0)
            /** This is the azimuth of the spacecraft wrt the frame x vector, in radians. Will be zero if masked */
            SIGNAL(azimuth,                 double,                 0.0)
            /** This is the elevation of the spacecraft wrt the frame x-y plane, in radians. Will be zero if masked. */
            SIGNAL(elevation,               double,                 0.0)
            /** This is the mask flag for the ground station. True for masked, False for visible */
            SIGNAL(masked,                  bool,                   true)
            /** The position of the ground station as measured in the planet-centered inertial frame */
            SIGNAL(gs_position__pci,        CartesianVector3,      CartesianVector3())
            /** The velocity of the ground station as measured in the planet-centered inertial frame */
            SIGNAL(gs_velocity__pci,        CartesianVector3,      CartesianVector3())
            /** Pointer to the ground station model for GUI linking of Ground Station model */
            SIGNAL(self_ptr,                clockwerk::GraphTreeObject*,nullptr)
        END_OUTPUTS

        // Getters for handles to respective submodels
        // TODO: Fix this to not be needed because these can all be public. Until then it's here
        clockwerk::DataIO<Frame*> enuFrame = clockwerk::DataIO<Frame*>(this, "enuFrame", &_enu_frame);
        warptwin::FrameStateSensorModel* frameStateSensorEnu() {return &_fss_enu;}
        warptwin::RangeAzElSensorModel* rangeAzElSensor() {return &_range_az_el_sensor;}
    protected:
        int16 start() override;
        int16 execute() override; 

        /// @brief The ENU frame created for the GS by this model
        Frame _enu_frame; 

        /// @brief The frame state sensor for relative states to the ENU frame
        FrameStateSensorModel _fss_enu;

        /// @brief The range az el sensor for our actual ground station
        RangeAzElSensorModel _range_az_el_sensor;

        /// @brief The frame state sensor for GS state in the PCI frame
        FrameStateSensorModel _fss_gs_pci;
    };

}

#endif