Fix for motor mass curve calculation
This commit is contained in:
parent
c58edfa30f
commit
47919b661f
@ -31,6 +31,9 @@ set(BUILD_CURL_EXE OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(HTTP_ONLY ON)
|
||||
set(SSL_ENABLED ON)
|
||||
if(WIN32)
|
||||
set(CURL_USE_SCHANNEL ON)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(CURL)
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
// qtrocket headers
|
||||
#include "QtRocket.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
// Initialize static member data
|
||||
@ -23,6 +24,8 @@ bool QtRocket::initialized = false;
|
||||
// The gui worker thread
|
||||
void guiWorker(int argc, char* argv[], int& ret)
|
||||
{
|
||||
utils::Logger* logger = utils::Logger::getInstance();
|
||||
logger->info("Starting QApplication");
|
||||
QApplication a(argc, argv);
|
||||
a.setWindowIcon(QIcon(":/qtrocket.png"));
|
||||
|
||||
@ -42,6 +45,7 @@ void guiWorker(int argc, char* argv[], int& ret)
|
||||
|
||||
// Go!
|
||||
MainWindow w(QtRocket::getInstance());
|
||||
logger->info("Showing MainWindow");
|
||||
w.show();
|
||||
ret = a.exec();
|
||||
|
||||
@ -61,6 +65,7 @@ void QtRocket::init()
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if(!initialized)
|
||||
{
|
||||
utils::Logger::getInstance()->info("Instantiating new QtRocket");
|
||||
instance = new QtRocket();
|
||||
initialized = true;
|
||||
}
|
||||
|
@ -89,6 +89,17 @@ double MotorModel::getThrust(double simTime)
|
||||
void MotorModel::setMetaData(const MetaData& md)
|
||||
{
|
||||
data = md;
|
||||
computeMassCurve();
|
||||
}
|
||||
|
||||
void MotorModel::moveMetaData(MetaData&& md)
|
||||
{
|
||||
data = std::move(md);
|
||||
computeMassCurve();
|
||||
}
|
||||
|
||||
void MotorModel::computeMassCurve()
|
||||
{
|
||||
emptyMass = data.totalWeight - data.propWeight;
|
||||
|
||||
// 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;
|
||||
}
|
||||
massCurve.push_back(std::make_pair(data.burnTime, 0.0));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MotorModel::moveMetaData(MetaData&& md)
|
||||
{
|
||||
data = std::move(md);
|
||||
}
|
||||
} // namespace model
|
||||
|
@ -412,6 +412,8 @@ private:
|
||||
ThrustCurve thrust; /// The measured motor thrust curve
|
||||
|
||||
std::vector<std::pair<double, double>> massCurve;
|
||||
|
||||
void computeMassCurve();
|
||||
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
* @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(double simTime) const { return mass + mm.getMass(simTime); }
|
||||
|
||||
/**
|
||||
* @brief setMass sets the current total mass of the Rocket
|
||||
|
@ -92,7 +92,7 @@ void Propagator::runUntilTerminate()
|
||||
|
||||
double Propagator::getMass()
|
||||
{
|
||||
return rocket->getMass();
|
||||
return rocket->getMass(currentTime);
|
||||
}
|
||||
|
||||
double Propagator::getForceX()
|
||||
|
@ -71,7 +71,8 @@ void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
|
||||
mm.length = v.get<double>("<xmlattr>.len", 0.0);
|
||||
mm.manufacturer = model::MotorModel::MotorManufacturer::toEnum(v.get<std::string>("<xmlattr>.mfg", ""));
|
||||
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.type = model::MotorModel::MotorType::toEnum(v.get<std::string>("<xmlattr>.Type"));
|
||||
|
@ -14,7 +14,7 @@ namespace utils
|
||||
{
|
||||
|
||||
ThrustCurveAPI::ThrustCurveAPI()
|
||||
: hostname("http://www.thrustcurve.org/"),
|
||||
: hostname("https://www.thrustcurve.org/"),
|
||||
curlConnection()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user