Fix crash on motor load
This commit is contained in:
parent
f4e560fcd9
commit
6a015d9797
@ -7,6 +7,10 @@ namespace model
|
|||||||
|
|
||||||
Rocket::Rocket()
|
Rocket::Rocket()
|
||||||
{
|
{
|
||||||
|
// A rocket needs at least one stage. Upon creation, we need to create at least one stage
|
||||||
|
currentStage.reset(new Stage("sustainer"));
|
||||||
|
stages.push_back(currentStage);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +43,7 @@ double Rocket::getMass(double t)
|
|||||||
double totalMass = 0.0;
|
double totalMass = 0.0;
|
||||||
for(const auto& stage : stages)
|
for(const auto& stage : stages)
|
||||||
{
|
{
|
||||||
totalMass += stage.second->getMass(t);
|
totalMass += stage->getMass(t);
|
||||||
}
|
}
|
||||||
return totalMass;
|
return totalMass;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
/// \cond
|
/// \cond
|
||||||
// C headers
|
// C headers
|
||||||
// C++ headers
|
// C++ headers
|
||||||
#include <map>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility> // std::move
|
#include <utility> // std::move
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
* @param t current simulation time
|
* @param t current simulation time
|
||||||
* @return mass in kg
|
* @return mass in kg
|
||||||
*/
|
*/
|
||||||
virtual double getMass(double t) override;
|
double getMass(double t) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief setMotorModel
|
* @brief setMotorModel
|
||||||
@ -84,8 +84,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setName(const std::string& n) { name = n; }
|
void setName(const std::string& n) { name = n; }
|
||||||
|
|
||||||
virtual double getDragCoefficient() override { return 1.0; }
|
double getDragCoefficient() override { return 1.0; }
|
||||||
virtual void setDragCoefficient(double d) override { }
|
void setDragCoefficient(double d) override { }
|
||||||
void setMass(double m) { }
|
void setMass(double m) { }
|
||||||
|
|
||||||
std::shared_ptr<Stage> getCurrentStage() { return currentStage; }
|
std::shared_ptr<Stage> getCurrentStage() { return currentStage; }
|
||||||
@ -94,7 +94,7 @@ private:
|
|||||||
|
|
||||||
std::string name; /// Rocket name
|
std::string name; /// Rocket name
|
||||||
|
|
||||||
std::map<unsigned int, std::shared_ptr<Stage>> stages;
|
std::vector<std::shared_ptr<Stage>> stages;
|
||||||
std::shared_ptr<Stage> currentStage;
|
std::shared_ptr<Stage> currentStage;
|
||||||
//model::MotorModel mm; /// Current Motor Model
|
//model::MotorModel mm; /// Current Motor Model
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
namespace model
|
namespace model
|
||||||
{
|
{
|
||||||
|
|
||||||
Stage::Stage()
|
Stage::Stage(const std::string& inName)
|
||||||
|
: name(inName)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Stage::~Stage()
|
Stage::~Stage()
|
||||||
|
@ -21,7 +21,7 @@ namespace model
|
|||||||
class Stage : public Propagatable
|
class Stage : public Propagatable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Stage();
|
Stage(const std::string& inName);
|
||||||
virtual ~Stage();
|
virtual ~Stage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user