ModelSpace
Documentation for ModelSpace models and classes.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
/******************************************************************************
* Copyright (c) ATTX LLC 2024. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the 
* proprietary and confidential information of ATTX, LLC. 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, LLC.
******************************************************************************/
/*
Frams state sensor model header file

Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"exclude" : True}
*/

#ifndef MODELS_SUPPORT_LVLH_FRAME_MODEL_H
#define MODELS_SUPPORT_LVLH_FRAME_MODEL_H

#include "simulation/Model.h"
#include "frames/Frame.h"
#include "frames/frameutils.h"

namespace modelspace {

    /**
     * @brief   LVLV Frame Manager Model
     * 
     * This model creates and maintains the LVLH reference frame 
     * according to the NASA definition here:
     * https://ntrs.nasa.gov/api/citations/19780010162/downloads/19780010162.pdf
     * 
     * It creates a frame as a child of the parent frame parameterized by
     * parent. It locks position to the parent frame, leaves attitude free,
     * then updates attitude at every derivative step according to the LVLH 
     * frame definition.
     * 
     * Definition:
     * +Z axis directed toward the center of the Earth
     * +Y axis perpendicular to the orbit plane with direction opposite angular momentum
     * +X axis completes the right hand frame in the direction of orbit travel
     * 
     * Important: This is a position-only frame. Angular velocity is not updated
    */
    MODEL(LvlhFrameManagerModel)
    public:
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** The inertial parent frame which the target frame is orbiting */
            SIGNAL(planet_frame_ptr,        Frame*,                nullptr)
            /** The reference target frame to which the LVLH frame should attach */
            SIGNAL(target_frame_ptr,        Frame*,                nullptr)
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS
            /** This is the orbital position of the object for which we're calculating LVLH */
            SIGNAL(pos__inertial,           CartesianVector3,      CartesianVector3())
            /** This is the orbital velocity of the object for which we're calculating LVLH */
            SIGNAL(vel__inertial,           CartesianVector3,      CartesianVector3())
        END_INPUTS

        // Model outputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_OUTPUTS
            /** The LVLH frame produced by this model */
            SIGNAL(lvlh_frame_ptr,          Frame*,                nullptr)
        END_OUTPUTS 

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

        /// @brief  This is the actual LVLH frame
        Frame _lvlh_frame = Frame("lvlh_frame");

        /// @brief Temporary variable to hold lvlh attitude
        clockwerk::DCM _lvlh_attitude__r;

        /// @brief Temporary variable to hold LVLH angular velociyt in lvlh frame
        CartesianVector3 _lvlh_ang_vel__lvlh;
    };

}

#endif