From c2979e31180a97bfc3feec0b6370ca8ff96941f0 Mon Sep 17 00:00:00 2001 From: Travis Hunter Date: Sat, 22 Apr 2023 19:35:29 -0600 Subject: [PATCH] Adding more motor manufacturers to MOTORMANUFACTURER enum class and MotorManufacturer struct --- model/MotorModel.h | 58 +++++++++++++++++++++++++++++++---- model/Rocket.h | 74 ++++++++++++++++++++++++++++++++++++++++++--- model/ThrustCurve.h | 19 ++---------- 3 files changed, 123 insertions(+), 28 deletions(-) diff --git a/model/MotorModel.h b/model/MotorModel.h index 7bc5593..b5df4cb 100644 --- a/model/MotorModel.h +++ b/model/MotorModel.h @@ -77,11 +77,15 @@ public: enum class MOTORMANUFACTURER { AEROTECH, - CESARONI, - LOKI, AMW, - ESTES, APOGEE, + CESARONI, + CONTRAIL, + ESTES, + HYPERTEK, + KLIMA, + LOKI, + QUEST, UNKNOWN }; @@ -138,6 +142,11 @@ public: return std::string("OOP"); } + /** + * @brief toEnum returns AVAILABILITY enum from string name + * @param name Name of enum + * @return AVAILABILITY enum corresponding to name + */ static AVAILABILITY toEnum(const std::string& name) { if(name == "regular") @@ -182,6 +191,12 @@ public: else // UNK - Unknown return std::string("Unkown"); } + + /** + * @brief toEnum returns CERTORG enum corresponding to name + * @param name Name of enumeration + * @return enumeration value corresponding to name + */ static CERTORG toEnum(const std::string& name) { if(name == "AMRS") @@ -229,6 +244,12 @@ public: else return std::string("Hybrid"); } + + /** + * @brief toEnum returns enumeration corresponding to name + * @param name Name of enumeration + * @return enumeration corresponding to name + */ static MOTORTYPE toEnum(const std::string& name) { if(name == "SU" || @@ -278,26 +299,51 @@ public: return std::string("Loki"); case MOTORMANUFACTURER::APOGEE: return std::string("Apogee"); + case MOTORMANUFACTURER::CONTRAIL: + return std::string("Contrail"); + case MOTORMANUFACTURER::HYPERTEK: + return std::string("Hypertek"); + case MOTORMANUFACTURER::KLIMA: + return std::string("Klima"); + case MOTORMANUFACTURER::QUEST: + return std::string("Quest"); case MOTORMANUFACTURER::UNKNOWN: default: return std::string("Unknown"); } } + + /** + * @brief toEnum returns MOTORMANUFACTURER enum value corresponding to a name + * @param name Name of enumeration + * @return enumeration corresponding to name + */ static MOTORMANUFACTURER toEnum(const std::string& name) { if(name == "AeroTech" || name == "Aerotech") return MOTORMANUFACTURER::AEROTECH; - else if(name == "AMW") + else if(name == "AMW" || + name == "Animal Motor Works") return MOTORMANUFACTURER::AMW; - else if(name == "Cesaroni") + else if(name == "Cesaroni" || + name == "Cesaroni Technology Inc.") return MOTORMANUFACTURER::CESARONI; - else if(name == "Estes") + else if(name == "Estes" || + name == "Estes Industries, Inc.") return MOTORMANUFACTURER::ESTES; else if(name == "Loki") return MOTORMANUFACTURER::LOKI; else if(name == "Apogee") return MOTORMANUFACTURER::APOGEE; + else if(name == "Contrail") + return MOTORMANUFACTURER::CONTRAIL; + else if(name == "Hypertek") + return MOTORMANUFACTURER::HYPERTEK; + else if(name == "Klima") + return MOTORMANUFACTURER::QUEST; + else if(name == "Quest") + return MOTORMANUFACTURER::KLIMA; else return MOTORMANUFACTURER::UNKNOWN; } diff --git a/model/Rocket.h b/model/Rocket.h index 0cb7473..fb24f8d 100644 --- a/model/Rocket.h +++ b/model/Rocket.h @@ -5,6 +5,7 @@ // C headers // C++ headers #include +#include #include // std::move // 3rd party headers @@ -12,6 +13,7 @@ // qtrocket headers #include "model/ThrustCurve.h" +#include "model/MotorModel.h" #include "sim/Propagator.h" /** @@ -26,31 +28,93 @@ public: */ Rocket(); + /** + * @brief launch Propagates the Rocket object until termination, + * normally when altitude crosses from positive to negative + */ void launch(); + + /** + * @brief getStates returns a vector of time/state pairs generated during launch() + * @return vector of pairs of doubles, where the first value is a time and the second a state vector + */ const std::vector>>& getStates() const { return propagator.getStates(); } + /** + * @brief setInitialState sets the initial state of the Rocket. + * @param initState initial state vector (x, y, z, xDot, yDot, zDot, pitch, yaw, roll, pitchDot, yawDot, rollDot) + */ void setInitialState(const std::vector& initState) { propagator.setInitialState(initState); } + /** + * @brief getMass returns the current mass of the rocket. This is the sum of all components' masses + * @return total current mass of the Rocket + */ double getMass() const { return mass; } + + /** + * @brief setMass sets the current total mass of the Rocket + * @param m total Rocket mass + * @todo This should be dynamically computed, not set. Fix this + */ void setMass(double m) { mass = m;} + /** + * @brief setDragCoefficient sets the current total drag coefficient of the Rocket + * @param d drag coefficient + * @todo This should be dynamically computed, not set. Fix this + */ void setDragCoefficient(double d) { dragCoeff = d; } + + /** + * @brief getDragCoefficient returns the current drag coefficient + * + * This is intended to be called by the propagator during propagation. + * @return the coefficient of drag + */ double getDragCoefficient() const { return dragCoeff; } + /** + * @brief getThrust returns current motor thrust + * @param t current simulation time + * @return thrust in Newtons + */ double getThrust(double t); + + /** + * @brief setThrustCurve sets the current thrust curve + * @param curve + * @todo Remove this + */ void setThrustCurve(const ThrustCurve& curve); + /** + * @brief setMotorModel + * @param motor + */ + void setMotorModel(const model::MotorModel& motor); + + /** + * @brief terminateCondition returns true or false, whether the passed-in time/state matches the terminate condition + * @param cond time/state pair + * @return true if the passed-in time/state satisfies the terminate condition + */ bool terminateCondition(const std::pair>& cond); + /** + * @brief setName sets the rocket name + * @param n name to set the Rocket + */ void setName(const std::string& n) { name = n; } private: - std::string name; - sim::Propagator propagator; - double dragCoeff; - double mass; + std::string name; /// Rocket name + sim::Propagator propagator; /// propagator + double dragCoeff; /// @todo get rid of this, should be dynamically calculated + double mass; /// @todo get rid of this, should be dynamically computed, but is the current rocket mass - ThrustCurve tc; + model::MotorModel mm; /// Current Motor Model + ThrustCurve tc; /// @todo get rid of this, should be returned from the MotorModel }; diff --git a/model/ThrustCurve.h b/model/ThrustCurve.h index d0b0a5b..37467fc 100644 --- a/model/ThrustCurve.h +++ b/model/ThrustCurve.h @@ -7,8 +7,6 @@ #include // 3rd party headers -#include -#include /// \endcond class ThrustCurve @@ -59,27 +57,14 @@ public: void setIgnitionTime(double t); /** - * TODO: Get rid of this. This is for temporary testing - */ + * TODO: Get rid of this. This is for temporary testing + */ void setThrustCurveVector(const std::vector>& v); - private: - // We're using boost::serialize for data storage and retrieval - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version); - std::vector> thrustCurve; double maxTime{0.0}; double ignitionTime{0.0}; }; -template -void ThrustCurve::serialize(Archive& ar, const unsigned int version) -{ - ar & maxTime; - ar & thrustCurve; -} - #endif // MODEL_THRUSTCURVE_H