mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 15:17:23 +00:00
Resolve "More verbose simulation results"
This commit is contained in:
parent
11b7b41469
commit
b30154a62d
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"ms-vscode.cpptools",
|
"ms-vscode.cpptools",
|
||||||
"wayou.vscode-todo-highlight"
|
"wayou.vscode-todo-highlight",
|
||||||
|
"usernamehw.errorlens"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include "outVector.h"
|
#include "outVector.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void burnStartTimeCalc(struct Vehicle &);
|
void burnStartTimeCalc(struct Vehicle &);
|
||||||
void thrustSelection(struct Vehicle &, int t);
|
void thrustSelection(struct Vehicle &, int t);
|
||||||
void lqrCalc(struct Vehicle &);
|
void lqrCalc(struct Vehicle &);
|
||||||
@ -38,19 +40,33 @@ bool sim(struct Vehicle &State, struct Vehicle &PrevState) {
|
|||||||
|
|
||||||
write2CSV(stateVector, State);
|
write2CSV(stateVector, State);
|
||||||
|
|
||||||
bool returnValue;
|
bool pass = 1;
|
||||||
|
|
||||||
if (abs(State.vz) < 5) {
|
double landing_angle =
|
||||||
if ((abs(State.yaw) < 5) && (abs(State.pitch) < 5)) {
|
pow(State.yaw * State.yaw + State.pitch * State.pitch, .5);
|
||||||
returnValue = 1;
|
|
||||||
} else {
|
double landing_velocity =
|
||||||
returnValue = 0;
|
pow(State.vx * State.vx + State.vy * State.vy + State.vz * State.vz, .5);
|
||||||
}
|
|
||||||
|
if (landing_angle < 5.0) {
|
||||||
|
std::cout << " Landing Angle < 5° | PASS | ";
|
||||||
} else {
|
} else {
|
||||||
returnValue = 0;
|
std::cout << " Landing Angle < 5° | FAIL | ";
|
||||||
|
pass = pass * 0;
|
||||||
}
|
}
|
||||||
|
std::cout << "Final Angles: [" << State.yaw << ", " << State.pitch << "]"
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
return returnValue;
|
if (landing_velocity < 5.0) {
|
||||||
|
std::cout << "Landing Velocity < 5 m/s | PASS | ";
|
||||||
|
} else {
|
||||||
|
std::cout << "Landing Velocity < 5 m/s | FAIL | ";
|
||||||
|
pass = pass * 0;
|
||||||
|
}
|
||||||
|
std::cout << "Final Velocity: [" << State.vx << ", " << State.vy << ", "
|
||||||
|
<< State.vz << "]" << std::endl;
|
||||||
|
|
||||||
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void burnStartTimeCalc(Vehicle &State) {
|
void burnStartTimeCalc(Vehicle &State) {
|
||||||
@ -344,8 +360,6 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
|
|||||||
"pitchdot, rolldot, Servo1, Servo2, thrustFiring"
|
"pitchdot, rolldot, Servo1, Servo2, thrustFiring"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::cout << "Writing to csv...\n";
|
|
||||||
|
|
||||||
// writing to output file
|
// writing to output file
|
||||||
for (int t = 0; t < State.simTime; t++) {
|
for (int t = 0; t < State.simTime; t++) {
|
||||||
outfile << t << ", ";
|
outfile << t << ", ";
|
||||||
@ -377,6 +391,7 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
std::cout << "simOut.csv created successfully.\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
double derivative(double current, double previous, double step) {
|
double derivative(double current, double previous, double step) {
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -52,16 +52,8 @@ int main() {
|
|||||||
|
|
||||||
bool outcome = sim(State, PrevState);
|
bool outcome = sim(State, PrevState);
|
||||||
|
|
||||||
std::cout << "Finished"
|
std::cout << std::endl << "Simulation Complete 🚀" << std::endl;
|
||||||
<< "\n";
|
// ^^^
|
||||||
|
// 50% chance this makes Mattys linux crash
|
||||||
if (outcome == 1) {
|
return 0;
|
||||||
std::cout << "Sim Result = Success!";
|
|
||||||
return 0;
|
|
||||||
} else if (outcome == 0) {
|
|
||||||
std::cout << "Sim Result = Failed!";
|
|
||||||
// return 1; Until I figure out how to make CI/CD continue even when run
|
|
||||||
// fails.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user