WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
PlanetRelativeStatesModel.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.
******************************************************************************/
/*
Planet relative states model header file

Author: Gabriel Heredia Acevedo
*/
/* 
Metadata for MS GUI:
imdata = {"exclude" : True}
*/

#ifndef MODELS_STATES_PLANET_RELATIVE_STATES_MODEL_H
#define MODELS_STATES_PLANET_RELATIVE_STATES_MODEL_H

#include "simulation/Model.h"
#include "constants/planetdefaults.h"

namespace warptwin {

    /**
     * @brief   Model for determining the latitude, longitude, altitude state of a vehicle relative to an oblate planet
     * 
     * This model is a one-stop-shop for useful states of a vehicle relative to a 
     * celestial body. It uses the FrameStateSensor and planetrelutils from 
     * clockwerk internally 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 planetrelutils, which do the heavy 
     * lifting.
     * 
     * @author Gabe Heredia Acevedo <gabe@attx.tech>
    */
    MODEL(PlanetRelativeStatesModel)
    public:
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** This is the equatorial radius of the planet. Default is Earth in meters */
            SIGNAL(equatorial_radius,       double,                 warpos::earth_wgs84.eq_radius)
            /** The celestial body’s flattening parameter */
            SIGNAL(flattening,              double,                 warpos::earth_wgs84.flattening)
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS
            //TODO: Inputs might not be needed
            /** The cartesian position coordinates we will use to perform our calculations relative to the reference frame, typically Planet Centered Relative frame. */
            SIGNAL(pos__pcr,                CartesianVector3,       CartesianVector3({0.0, 0.0, 0.0}))
            /** The cartesian velocity coordinates we will use to perform our calculations relative to the reference frame, typically Planet Centered Relative frame. */
            SIGNAL(vel__pcr,                CartesianVector3,       CartesianVector3({0.0, 0.0, 0.0}))
            /** The quaternion which represents the nodal attitude relative to the reference frame, typically Planet Centered Relative frame. */
            SIGNAL(quat_obj_pcr,            clockwerk::Quaternion,  clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
            /** The attitude rate which represents the nodal attitude rate relative to the reference frame, typically Planet Centered Relative frame. */
            SIGNAL(angular_velocity_wrt_PCR,CartesianVector3,       CartesianVector3({0.0, 0.0, 0.0}))
        END_INPUTS

        // Model outputs
        //         NAME                            TYPE                    DEFAULT VALUE
        START_OUTPUTS
            /** The nodal detic latitude relative to the reference frame. Takes into account the ellipsoidal form of the celestial body.*/
            SIGNAL(latitude_detic,                 double,                 0.0)
            /** The nodal centric latitude relative to the reference frame. Assumes the celestial body is spherical.*/
            SIGNAL(latitude_centric,               double,                 0.0)
            /** The nodal detic altitude relative to the reference frame. Takes into account the ellipsoidal form of the celestial body.*/
            SIGNAL(altitude_detic,                 double,                 0.0)
            /** The nodal centric altitude relative to the reference frame. Assumes the celestial body is spherical.*/
            SIGNAL(altitude_centric,               double,                 0.0)
            /** The nodal longitude relative to the reference frame.*/
            SIGNAL(longitude,                      double,                 0.0)
        END_OUTPUTS

    protected:
        int16 start() override;
        int16 execute() override;  

        int _updateStates();

        /// @brief The radius set by the enum centric_by
        double _radius;
        double _polar_radius;
    };
}

#endif