1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-07-24 23:21:29 +00:00

Fixed differences between native and teensy, added getThrust() function to clean up thrustInfo()

This commit is contained in:
bpmcgeeney
2021-11-11 21:58:57 -07:00
parent f0577a8fce
commit 0058af9667
6 changed files with 61 additions and 65 deletions

View File

@@ -11,6 +11,7 @@ void state2vec(struct Vehicle &, struct Vehicle &, struct outVector &);
double derivative(double current, double previous, double step);
double integral(double currentChange, double prevValue, double dt);
double limit(double value, double upr, double lwr);
void getThrust(struct Vehicle &);
// Any parameters that are constants should be declared here instead of
// buried in code
@@ -254,4 +255,26 @@ double limit(double value, double upr, double lwr) {
value = value;
return value;
}
void getThrust(Vehicle &State) {
if ((State.burnElapsed > 0.147) && (State.burnElapsed < 0.420)) {
State.thrust = 65.165 * State.burnElapsed - 2.3921;
} else if ((State.burnElapsed > 0.419) && (State.burnElapsed < 3.383))
State.thrust = 0.8932 * pow(State.burnElapsed, 6.0) -
11.609 * pow(State.burnElapsed, 5.0) +
60.739 * pow(State.burnElapsed, 4.0) -
162.99 * pow(State.burnElapsed, 3.0) +
235.6 * pow(State.burnElapsed, 2.0) -
174.43 * State.burnElapsed + 67.17;
else if ((State.burnElapsed > 3.382) && (State.burnElapsed < 3.46)) {
State.thrust = -195.78 * State.burnElapsed + 675.11;
}
if (State.burnElapsed > 3.45) {
State.thrustFiring = 2;
State.thrust = 0.0;
}
}