Adding more motor manufacturers to MOTORMANUFACTURER enum class and MotorManufacturer struct

This commit is contained in:
Travis Hunter 2023-04-22 19:35:29 -06:00
parent 620cd80fe4
commit c2979e3118
3 changed files with 123 additions and 28 deletions

View File

@ -77,11 +77,15 @@ public:
enum class MOTORMANUFACTURER enum class MOTORMANUFACTURER
{ {
AEROTECH, AEROTECH,
CESARONI,
LOKI,
AMW, AMW,
ESTES,
APOGEE, APOGEE,
CESARONI,
CONTRAIL,
ESTES,
HYPERTEK,
KLIMA,
LOKI,
QUEST,
UNKNOWN UNKNOWN
}; };
@ -138,6 +142,11 @@ public:
return std::string("OOP"); 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) static AVAILABILITY toEnum(const std::string& name)
{ {
if(name == "regular") if(name == "regular")
@ -182,6 +191,12 @@ public:
else // UNK - Unknown else // UNK - Unknown
return std::string("Unkown"); 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) static CERTORG toEnum(const std::string& name)
{ {
if(name == "AMRS") if(name == "AMRS")
@ -229,6 +244,12 @@ public:
else else
return std::string("Hybrid"); 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) static MOTORTYPE toEnum(const std::string& name)
{ {
if(name == "SU" || if(name == "SU" ||
@ -278,26 +299,51 @@ public:
return std::string("Loki"); return std::string("Loki");
case MOTORMANUFACTURER::APOGEE: case MOTORMANUFACTURER::APOGEE:
return std::string("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: case MOTORMANUFACTURER::UNKNOWN:
default: default:
return std::string("Unknown"); 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) static MOTORMANUFACTURER toEnum(const std::string& name)
{ {
if(name == "AeroTech" || if(name == "AeroTech" ||
name == "Aerotech") name == "Aerotech")
return MOTORMANUFACTURER::AEROTECH; return MOTORMANUFACTURER::AEROTECH;
else if(name == "AMW") else if(name == "AMW" ||
name == "Animal Motor Works")
return MOTORMANUFACTURER::AMW; return MOTORMANUFACTURER::AMW;
else if(name == "Cesaroni") else if(name == "Cesaroni" ||
name == "Cesaroni Technology Inc.")
return MOTORMANUFACTURER::CESARONI; return MOTORMANUFACTURER::CESARONI;
else if(name == "Estes") else if(name == "Estes" ||
name == "Estes Industries, Inc.")
return MOTORMANUFACTURER::ESTES; return MOTORMANUFACTURER::ESTES;
else if(name == "Loki") else if(name == "Loki")
return MOTORMANUFACTURER::LOKI; return MOTORMANUFACTURER::LOKI;
else if(name == "Apogee") else if(name == "Apogee")
return MOTORMANUFACTURER::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 else
return MOTORMANUFACTURER::UNKNOWN; return MOTORMANUFACTURER::UNKNOWN;
} }

View File

@ -5,6 +5,7 @@
// C headers // C headers
// C++ headers // C++ headers
#include <memory> #include <memory>
#include <string>
#include <utility> // std::move #include <utility> // std::move
// 3rd party headers // 3rd party headers
@ -12,6 +13,7 @@
// qtrocket headers // qtrocket headers
#include "model/ThrustCurve.h" #include "model/ThrustCurve.h"
#include "model/MotorModel.h"
#include "sim/Propagator.h" #include "sim/Propagator.h"
/** /**
@ -26,31 +28,93 @@ public:
*/ */
Rocket(); Rocket();
/**
* @brief launch Propagates the Rocket object until termination,
* normally when altitude crosses from positive to negative
*/
void launch(); 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<std::pair<double, std::vector<double>>>& getStates() const { return propagator.getStates(); } const std::vector<std::pair<double, std::vector<double>>>& 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<double>& initState) { propagator.setInitialState(initState); } void setInitialState(const std::vector<double>& 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; } 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;} 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; } 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; } double getDragCoefficient() const { return dragCoeff; }
/**
* @brief getThrust returns current motor thrust
* @param t current simulation time
* @return thrust in Newtons
*/
double getThrust(double t); double getThrust(double t);
/**
* @brief setThrustCurve sets the current thrust curve
* @param curve
* @todo Remove this
*/
void setThrustCurve(const ThrustCurve& curve); 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<double, std::vector<double>>& cond); bool terminateCondition(const std::pair<double, std::vector<double>>& cond);
/**
* @brief setName sets the rocket name
* @param n name to set the Rocket
*/
void setName(const std::string& n) { name = n; } void setName(const std::string& n) { name = n; }
private: private:
std::string name; std::string name; /// Rocket name
sim::Propagator propagator; sim::Propagator propagator; /// propagator
double dragCoeff; double dragCoeff; /// @todo get rid of this, should be dynamically calculated
double mass; 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
}; };

View File

@ -7,8 +7,6 @@
#include <vector> #include <vector>
// 3rd party headers // 3rd party headers
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
/// \endcond /// \endcond
class ThrustCurve class ThrustCurve
@ -63,23 +61,10 @@ public:
*/ */
void setThrustCurveVector(const std::vector<std::pair<double, double>>& v); void setThrustCurveVector(const std::vector<std::pair<double, double>>& v);
private: private:
// We're using boost::serialize for data storage and retrieval
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version);
std::vector<std::pair<double, double>> thrustCurve; std::vector<std::pair<double, double>> thrustCurve;
double maxTime{0.0}; double maxTime{0.0};
double ignitionTime{0.0}; double ignitionTime{0.0};
}; };
template<class Archive>
void ThrustCurve::serialize(Archive& ar, const unsigned int version)
{
ar & maxTime;
ar & thrustCurve;
}
#endif // MODEL_THRUSTCURVE_H #endif // MODEL_THRUSTCURVE_H