Now reads motor delays
This commit is contained in:
parent
42298ca801
commit
821df8905a
@ -103,10 +103,6 @@ int QtRocket::run(int argc, char* argv[])
|
||||
|
||||
void QtRocket::addMotorModels(std::vector<model::MotorModel>& m)
|
||||
{
|
||||
for(const auto& i : m)
|
||||
{
|
||||
motorModels.push_back(i);
|
||||
}
|
||||
motorDatabase->addMotorModels(motorModels);
|
||||
motorDatabase->addMotorModels(m);
|
||||
// TODO: Now clear any duplicates?
|
||||
}
|
||||
|
@ -50,8 +50,6 @@ public:
|
||||
|
||||
void addMotorModels(std::vector<model::MotorModel>& m);
|
||||
|
||||
const std::vector<model::MotorModel>& getMotorModels() const { return motorModels; }
|
||||
|
||||
void addRocket(std::shared_ptr<Rocket> r) { rocket.first = r; }
|
||||
|
||||
void setEnvironment(std::shared_ptr<sim::Environment> e) { environment = e; }
|
||||
@ -66,9 +64,6 @@ private:
|
||||
static std::mutex mtx;
|
||||
static QtRocket* instance;
|
||||
|
||||
// Motor "database(s)"
|
||||
std::vector<model::MotorModel> motorModels;
|
||||
|
||||
utils::Logger* logger;
|
||||
|
||||
std::pair<std::shared_ptr<Rocket>, std::shared_ptr<sim::Propagator>> rocket;
|
||||
|
@ -107,6 +107,8 @@ public:
|
||||
void setName(const std::string& n) { name = n; }
|
||||
private:
|
||||
|
||||
|
||||
std::vector<double> bodyFrameState{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
||||
std::string name; /// Rocket name
|
||||
sim::Propagator propagator; /// propagator
|
||||
double dragCoeff; /// @todo get rid of this, should be dynamically calculated
|
||||
|
@ -4,8 +4,6 @@
|
||||
/// \cond
|
||||
// C headers
|
||||
// C++ headers
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/xml_parser.hpp>
|
||||
// 3rd party headers
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/xml_parser.hpp>
|
||||
@ -70,20 +68,6 @@ std::optional<model::MotorModel> MotorModelDatabase::getMotorModel(const std::st
|
||||
void MotorModelDatabase::saveMotorDatabase(const std::string& filename)
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
<MotorDatabase>
|
||||
<version>1.0</version>
|
||||
<MotorModels>
|
||||
<model name="XYZ">
|
||||
<totalWeight>10.0</totalWeight>
|
||||
<totalImpulse>123.4</totalImpulse>
|
||||
</model>
|
||||
</MotorModels>
|
||||
</MotorDatabase>
|
||||
|
||||
*/
|
||||
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
// top-level tree
|
||||
@ -114,6 +98,14 @@ void MotorModelDatabase::saveMotorDatabase(const std::string& filename)
|
||||
motor.put("type", m.data.type.str());
|
||||
motor.put("lastUpdated", m.data.lastUpdated);
|
||||
|
||||
std::stringstream delays;
|
||||
for (std::size_t i = 0; i < m.data.delays.size() - 1; ++i)
|
||||
{
|
||||
delays << std::to_string(m.data.delays[i]) << ",";
|
||||
}
|
||||
delays << std::to_string(m.data.delays[m.data.delays.size() - 1]);
|
||||
motor.put("delays", delays.str());
|
||||
|
||||
// thrust data
|
||||
{
|
||||
pt::ptree tc;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
// 3rd party headers
|
||||
#include <boost/property_tree/xml_parser.hpp>
|
||||
@ -58,6 +59,16 @@ void RSEDatabaseLoader::buildAndAppendMotorModel(boost::property_tree::ptree& v)
|
||||
mm.commonName = v.get<std::string>("<xmlattr>.code", "");
|
||||
|
||||
// mm.delays = extract vector from csv list
|
||||
std::string delays = v.get<std::string>("<xmlattr>.delays", "1000");
|
||||
std::size_t pos{0};
|
||||
std::string tok;
|
||||
while ((pos = delays.find(",")) != std::string::npos)
|
||||
{
|
||||
tok = delays.substr(0, pos);
|
||||
mm.delays.push_back(std::atoi(tok.c_str()));
|
||||
delays.erase(0, pos + 1);
|
||||
}
|
||||
mm.delays.push_back(std::atoi(delays.c_str()));
|
||||
|
||||
// mm.designation = What is this?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user