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
{
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;
}

View File

@ -5,6 +5,7 @@
// C headers
// C++ headers
#include <memory>
#include <string>
#include <utility> // 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<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); }
/**
* @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<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; }
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
};

View File

@ -7,8 +7,6 @@
#include <vector>
// 3rd party headers
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
/// \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<std::pair<double, double>>& v);
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;
double maxTime{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