Fix for motor mass curve calculation

This commit is contained in:
Travis Hunter 2023-05-03 18:46:14 -06:00
parent c58edfa30f
commit 47919b661f
8 changed files with 26 additions and 12 deletions

View File

@ -31,6 +31,9 @@ set(BUILD_CURL_EXE OFF)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
set(HTTP_ONLY ON) set(HTTP_ONLY ON)
set(SSL_ENABLED ON) set(SSL_ENABLED ON)
if(WIN32)
set(CURL_USE_SCHANNEL ON)
endif()
FetchContent_MakeAvailable(CURL) FetchContent_MakeAvailable(CURL)

View File

@ -12,6 +12,7 @@
// qtrocket headers // qtrocket headers
#include "QtRocket.h" #include "QtRocket.h"
#include "utils/Logger.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
// Initialize static member data // Initialize static member data
@ -23,6 +24,8 @@ bool QtRocket::initialized = false;
// The gui worker thread // The gui worker thread
void guiWorker(int argc, char* argv[], int& ret) void guiWorker(int argc, char* argv[], int& ret)
{ {
utils::Logger* logger = utils::Logger::getInstance();
logger->info("Starting QApplication");
QApplication a(argc, argv); QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/qtrocket.png")); a.setWindowIcon(QIcon(":/qtrocket.png"));
@ -42,6 +45,7 @@ void guiWorker(int argc, char* argv[], int& ret)
// Go! // Go!
MainWindow w(QtRocket::getInstance()); MainWindow w(QtRocket::getInstance());
logger->info("Showing MainWindow");
w.show(); w.show();
ret = a.exec(); ret = a.exec();
@ -61,6 +65,7 @@ void QtRocket::init()
std::lock_guard<std::mutex> lck(mtx); std::lock_guard<std::mutex> lck(mtx);
if(!initialized) if(!initialized)
{ {
utils::Logger::getInstance()->info("Instantiating new QtRocket");
instance = new QtRocket(); instance = new QtRocket();
initialized = true; initialized = true;
} }

View File

@ -89,6 +89,17 @@ double MotorModel::getThrust(double simTime)
void MotorModel::setMetaData(const MetaData& md) void MotorModel::setMetaData(const MetaData& md)
{ {
data = md; data = md;
computeMassCurve();
}
void MotorModel::moveMetaData(MetaData&& md)
{
data = std::move(md);
computeMassCurve();
}
void MotorModel::computeMassCurve()
{
emptyMass = data.totalWeight - data.propWeight; emptyMass = data.totalWeight - data.propWeight;
// Calculate the Isp for the motor, as we'll need this for the computing the mass flow rate. // Calculate the Isp for the motor, as we'll need this for the computing the mass flow rate.
@ -115,13 +126,5 @@ void MotorModel::setMetaData(const MetaData& md)
propMass -= thrust.getThrust(t + i*timeStep) * timeStep * data.propWeight / data.totalImpulse; propMass -= thrust.getThrust(t + i*timeStep) * timeStep * data.propWeight / data.totalImpulse;
} }
massCurve.push_back(std::make_pair(data.burnTime, 0.0)); massCurve.push_back(std::make_pair(data.burnTime, 0.0));
}
void MotorModel::moveMetaData(MetaData&& md)
{
data = std::move(md);
} }
} // namespace model } // namespace model

View File

@ -413,6 +413,8 @@ private:
std::vector<std::pair<double, double>> massCurve; std::vector<std::pair<double, double>> massCurve;
void computeMassCurve();
}; };
} // namespace model } // namespace model

View File

@ -50,7 +50,7 @@ public:
* @brief getMass returns the current mass of the rocket. This is the sum of all components' masses * @brief getMass returns the current mass of the rocket. This is the sum of all components' masses
* @return total current mass of the Rocket * @return total current mass of the Rocket
*/ */
double getMass() const { return mass; } double getMass(double simTime) const { return mass + mm.getMass(simTime); }
/** /**
* @brief setMass sets the current total mass of the Rocket * @brief setMass sets the current total mass of the Rocket

View File

@ -92,7 +92,7 @@ void Propagator::runUntilTerminate()
double Propagator::getMass() double Propagator::getMass()
{ {
return rocket->getMass(); return rocket->getMass(currentTime);
} }
double Propagator::getForceX() double Propagator::getForceX()

View File

@ -71,7 +71,8 @@ void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
mm.length = v.get<double>("<xmlattr>.len", 0.0); mm.length = v.get<double>("<xmlattr>.len", 0.0);
mm.manufacturer = model::MotorModel::MotorManufacturer::toEnum(v.get<std::string>("<xmlattr>.mfg", "")); mm.manufacturer = model::MotorModel::MotorManufacturer::toEnum(v.get<std::string>("<xmlattr>.mfg", ""));
mm.maxThrust = v.get<double>("<xmlattr>.peakThrust", 0.0); mm.maxThrust = v.get<double>("<xmlattr>.peakThrust", 0.0);
mm.propWeight = v.get<double>("<xmlattr>.propWt", 0.0); mm.totalWeight = v.get<double>("<xmlattr>.initWt", 0.0) / 1000.0; // convert g -> kg
mm.propWeight = v.get<double>("<xmlattr>.propWt", 0.0) / 1000.0; // convert g -> kg
mm.totalImpulse = v.get<double>("<xmlattr>.Itot", 0.0); mm.totalImpulse = v.get<double>("<xmlattr>.Itot", 0.0);
mm.type = model::MotorModel::MotorType::toEnum(v.get<std::string>("<xmlattr>.Type")); mm.type = model::MotorModel::MotorType::toEnum(v.get<std::string>("<xmlattr>.Type"));

View File

@ -14,7 +14,7 @@ namespace utils
{ {
ThrustCurveAPI::ThrustCurveAPI() ThrustCurveAPI::ThrustCurveAPI()
: hostname("http://www.thrustcurve.org/"), : hostname("https://www.thrustcurve.org/"),
curlConnection() curlConnection()
{ {