mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 15:17:23 +00:00
Changed pass condition
This commit is contained in:
parent
30cef521c0
commit
c62a8b0c44
@ -16,7 +16,7 @@ double limit(double value, double upr, double lwr);
|
|||||||
|
|
||||||
// Any parameters that are constants should be declared here instead of
|
// Any parameters that are constants should be declared here instead of
|
||||||
// buried in code
|
// buried in code
|
||||||
double const dt = 0.01;
|
double const dt = 0.001;
|
||||||
double const g = -9.81;
|
double const g = -9.81;
|
||||||
|
|
||||||
bool sim(struct Vehicle &State, struct Vehicle &PrevState) {
|
bool sim(struct Vehicle &State, struct Vehicle &PrevState) {
|
||||||
@ -35,13 +35,11 @@ bool sim(struct Vehicle &State, struct Vehicle &PrevState) {
|
|||||||
pidController(State, PrevState);
|
pidController(State, PrevState);
|
||||||
TVC(State, PrevState);
|
TVC(State, PrevState);
|
||||||
state2vec(State, PrevState, stateVector, t);
|
state2vec(State, PrevState, stateVector, t);
|
||||||
//std::cout << State.vz << "\n";
|
|
||||||
|
|
||||||
t += State.stepSize;
|
t += State.stepSize;
|
||||||
} while ((State.z > 0.0));
|
} while ((State.z > 0.0));
|
||||||
std::cout << t << "\n";
|
|
||||||
write2CSV(stateVector, State, t);
|
write2CSV(stateVector, State, t);
|
||||||
std::cout << t << "\n";
|
|
||||||
|
|
||||||
bool pass = 1;
|
bool pass = 1;
|
||||||
|
|
||||||
@ -60,10 +58,10 @@ std::cout << t << "\n";
|
|||||||
std::cout << "Final Angles: [" << State.yaw << ", " << State.pitch << "]"
|
std::cout << "Final Angles: [" << State.yaw << ", " << State.pitch << "]"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
if (landing_velocity < 5.0) {
|
if (landing_velocity < 0.5) {
|
||||||
std::cout << "Landing Velocity < 5 m/s | PASS | ";
|
std::cout << "Landing Velocity < 0.5 m/s | PASS | ";
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Landing Velocity < 5 m/s | FAIL | ";
|
std::cout << "Landing Velocity < 0.5 m/s | FAIL | ";
|
||||||
pass = pass * 0;
|
pass = pass * 0;
|
||||||
}
|
}
|
||||||
std::cout << "Final Velocity: [" << State.vx << ", " << State.vy << ", "
|
std::cout << "Final Velocity: [" << State.vx << ", " << State.vy << ", "
|
||||||
@ -76,7 +74,7 @@ void burnStartTimeCalc(Vehicle &State) {
|
|||||||
double velocity = State.vz;
|
double velocity = State.vz;
|
||||||
double h = 0;
|
double h = 0;
|
||||||
|
|
||||||
double mass, thrust;
|
double mass, thrust, acceleration;
|
||||||
|
|
||||||
// Piecewise functions for F15 thrust curve
|
// Piecewise functions for F15 thrust curve
|
||||||
for (double i = 0.148; i < 3.450; i = i + dt) {
|
for (double i = 0.148; i < 3.450; i = i + dt) {
|
||||||
@ -92,11 +90,14 @@ void burnStartTimeCalc(Vehicle &State) {
|
|||||||
else if ((i > 3.382) && (i < 3.46))
|
else if ((i > 3.382) && (i < 3.46))
|
||||||
thrust = -195.78 * i + 675.11;
|
thrust = -195.78 * i + 675.11;
|
||||||
|
|
||||||
velocity = (((thrust / mass) + g) * dt) + velocity;
|
acceleration = (thrust / mass) + g;
|
||||||
h = (((thrust / mass) + g) * dt) + h;
|
velocity = integral(acceleration, velocity, State.stepSize);
|
||||||
|
h = integral(velocity, h, State.stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
State.z = h + (pow(velocity, 2) / (2 * -g)); // starting height
|
State.z = h + (pow(velocity, 2) / (2 * -g)); // starting height
|
||||||
State.burnVelocity = velocity; // terminal velocity
|
State.burnVelocity = velocity; // terminal velocity
|
||||||
|
std::cout << State.z << std::endl;
|
||||||
|
|
||||||
double burnStartTime = State.burnVelocity / -g;
|
double burnStartTime = State.burnVelocity / -g;
|
||||||
State.simTime = (State.burntime + burnStartTime) * 1000;
|
State.simTime = (State.burntime + burnStartTime) * 1000;
|
||||||
@ -172,6 +173,15 @@ void vehicleDynamics(Vehicle &State, Vehicle &PrevState, int t) {
|
|||||||
State.vx = integral(State.ax, PrevState.vx, State.stepSize);
|
State.vx = integral(State.ax, PrevState.vx, State.stepSize);
|
||||||
State.vy = integral(State.ay, PrevState.vy, State.stepSize);
|
State.vy = integral(State.ay, PrevState.vy, State.stepSize);
|
||||||
State.vz = integral(State.az, PrevState.vz, State.stepSize);
|
State.vz = integral(State.az, PrevState.vz, State.stepSize);
|
||||||
|
/*
|
||||||
|
// Xe
|
||||||
|
State.x = 0.5 * State.ax * pow(State.stepSize, 2) +
|
||||||
|
State.vx * State.stepSize + PrevState.x;
|
||||||
|
State.y = 0.5 * State.ay * pow(State.stepSize, 2) +
|
||||||
|
State.vy * State.stepSize + PrevState.y;
|
||||||
|
State.z = 0.5 * State.az * pow(State.stepSize, 2) +
|
||||||
|
State.vz * State.stepSize + PrevState.z;
|
||||||
|
*/
|
||||||
|
|
||||||
// Xe
|
// Xe
|
||||||
State.x = integral(State.vx, PrevState.x, State.stepSize);
|
State.x = integral(State.vx, PrevState.x, State.stepSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user