Skip to content
Snippets Groups Projects
Commit ec136d14 authored by Emilio Corigliano's avatar Emilio Corigliano Committed by Davide Mor
Browse files

[MEA] Fixed bugs and added some documentation

- Initialized mass parameter
- Fixed apogee estimation massive formula
- Simplified apogee estimation formula splitting it
- Added some documentation
parent 081d1571
Branches
No related tags found
No related merge requests found
...@@ -61,10 +61,11 @@ void MEA::Step::withSpeedAndAlt(float verticalSpeed, float mslAltitude) ...@@ -61,10 +61,11 @@ void MEA::Step::withSpeedAndAlt(float verticalSpeed, float mslAltitude)
MEA::MEA(const Config &config) MEA::MEA(const Config &config)
: F{config.F}, Q{config.Q}, G{config.G}, baroH{config.baroH}, : F{config.F}, Q{config.Q}, G{config.G}, baroH{config.baroH},
baroR{config.baroR}, P{config.P}, x{0, 0, config.initialMass}, baroR{config.baroR}, P{config.P}, x{0, 0, config.initialMass},
accelThresh{config.accelThresh}, speedThresh{config.speedThresh}, mass{config.initialMass}, accelThresh{config.accelThresh},
Kt{config.Kt}, alpha{config.alpha}, c{config.c}, coeffs{config.coeffs}, speedThresh{config.speedThresh}, Kt{config.Kt}, alpha{config.alpha},
crossSection{config.crossSection}, ae{config.ae}, p0{config.p0}, c{config.c}, coeffs{config.coeffs}, crossSection{config.crossSection},
minMass{config.minMass}, maxMass{config.maxMass} ae{config.ae}, p0{config.p0}, minMass{config.minMass}, maxMass{
config.maxMass}
{ {
updateState(); updateState();
} }
...@@ -181,12 +182,12 @@ void MEA::computeApogee(const Step &step) ...@@ -181,12 +182,12 @@ void MEA::computeApogee(const Step &step)
if (!step.hasSpeedAndAlt) if (!step.hasSpeedAndAlt)
return; return;
// TODO: Matlab uses CD_correction_shutDown, should we? // Simplified massive formula for apogee estimation.
// Holy fuck, massive formula, split this for the love of god // Warning: log1p(x) = log(1 + x)
float temp = ((rho * cd * crossSection) / mass);
apogee = step.mslAltitude + apogee = step.mslAltitude +
1 / (2 * ((0.5f * rho * cd * crossSection) / mass)) * 1 / temp *
log1p(1 + (step.verticalSpeed * step.verticalSpeed * log1p(0.5 * (step.verticalSpeed * step.verticalSpeed * temp) /
((0.5f * rho * cd * crossSection) / mass)) /
Constants::g); Constants::g);
} }
......
...@@ -128,8 +128,8 @@ private: ...@@ -128,8 +128,8 @@ private:
float q = 0.0f; //< Latest computed dynamic pressure float q = 0.0f; //< Latest computed dynamic pressure
float force = 0.0f; //< Latest computed force float force = 0.0f; //< Latest computed force
float mass = 0.0f; //< Latest computed mass
float apogee = 0.0f; //< Latest computed apogee float apogee = 0.0f; //< Latest computed apogee
float mass; //< Latest computed mass
float accelThresh; float accelThresh;
float speedThresh; float speedThresh;
......
...@@ -32,20 +32,19 @@ struct MEAState ...@@ -32,20 +32,19 @@ struct MEAState
{ {
uint64_t timestamp; uint64_t timestamp;
float estimatedPressure; float estimatedPressure; ///< Estimated pressure in combustion chamber [Pa]
float estimatedMass; float estimatedMass; ///< Estimated rocket mass [kg]
float estimatedApogee; float estimatedApogee; ///< Estimated apogee in msl [m]
float estimatedForce; float estimatedForce; ///< Estimated drag force [N]
float x0; float x0; ///< first kalman state
float x1; float x1; ///< second kalman state
float x2; float x2; ///< third kalman state representing the mass
static std::string header() static std::string header()
{ {
return "timestamp,estimatedPressure,estimatedMass,estimatedApogee," return "timestamp,estimatedPressure,estimatedMass,estimatedApogee,"
"estimatedForce,x0," "estimatedForce,x0,x1,x2\n";
"x1,x2\n";
} }
void print(std::ostream &os) const void print(std::ostream &os) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment