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.
******************************************************************************/
/*
Impulse model header file

Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Timed Impulsive Burn",
          "exclude" : False,
          "category" : "GN&C"
}
aliases = {"body_frame" : "Spacecraft Body",
           "burn_frame" : "Frame of Burn Vector",
           "time_of_ignition" : "Burn Time",
           "deltav__burn" : "Burn Vector",
           "current_time" : "Time"
}
*/
#ifndef MODELS_ACTUATORS_TIMED_IMPULSIVE_BURN_MODEL_H
#define MODELS_ACTUATORS_TIMED_IMPULSIVE_BURN_MODEL_H

#include "simulation/Model.h"
#include "core/CartesianVector.hpp"
#include "frames/Frame.h"
#include "frames/Body.h"
#include "frames/Node.h"
#include "models/actuators/ImpulseModel.h"
#include "monitors/TimeTriggerMonitor.h"

namespace modelspace {

    /**
     * @brief   Model which applies a fixed impulse to a vehicle at a set sim or UTC time
     * 
     * This model is used for mission planning to program an impulsive burn to occur
     * at a specific time and in a specific frame. The model internally uses a 
     * time trigger monitor, ImpulseModel, and node to apply a force to a specific
     * body in the simulation. 
     * 
     * Once triggered, the impulsive burn model will not trigger again until reset.
     * 
     * Author: Alex Reynolds <alex.reynolds@attx.tech>
    */
    MODEL(TimedImpulsiveBurnModel)
    public:
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** The body frame of the spacecraft which will be performing the burn */
            SIGNAL(body_frame,              Body*,                 nullptr)
            /** The frame in which the burn will be executed. If not set, will execute in the body frame */
            SIGNAL(burn_frame,              Frame*,                nullptr)
            /** The time of ignition of the burn. This may be in simulation time or ephemeris time,
             *  depending on which source the Time input is connected to. */
            SIGNAL(time_of_ignition,        clockwerk::Time,        clockwerk::Time(UINT32_MAX, 0))
            /** The impulsive burn vector, in m/s, to be executed at the time of ignition. This vector
                will be as represented in the Burn Frame  */
            SIGNAL(deltav__burn,            CartesianVector3,      CartesianVector3({0.0, 0.0, 0.0}))
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS
            /** The current time in the same timescale as the parameterized TIG */
            SIGNAL(current_time,            clockwerk::Time,        clockwerk::Time())
        END_INPUTS

        // Model outputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_OUTPUTS
        
        END_OUTPUTS

        /// @brief Function to get a handle to the time trigger monitor contained within this model
        /// @return Pointer to the time trigger monitor
        modelspace::TimeTriggerMonitor* timeTriggerMonitor() {return &_time_trigger;}
        /// @brief Function to get a handle to the impulse model contained within this model
        /// @return Pointer to the impulse model
        modelspace::ImpulseModel* impulseModel() {return &_impulse;}
    protected:
        int16 start() override;
        int16 execute() override; 

        // Internal models and monitors
        TimeTriggerMonitor _time_trigger;
        ImpulseModel _impulse;

        // Node at which forces will be applied
        Node _force_node;

        // Boolean indicating whether trigger has happened before
        bool _triggered = false;
    };
}

#endif