diff --git a/include/outVector.h b/include/outVector.h index e40535d..0bbbf83 100644 --- a/include/outVector.h +++ b/include/outVector.h @@ -3,7 +3,6 @@ #ifndef OUTVECTOR_H #define OUTVECTOR_H - struct outVector { int length = 10000; // current sim runs ~5000 steps, x2 just in case diff --git a/include/sim.h b/include/sim.h index fa3b5e3..debdf0e 100644 --- a/include/sim.h +++ b/include/sim.h @@ -7,7 +7,7 @@ void lqrCalc(struct Vehicle &); void TVC(struct Vehicle &); void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t); void state2vec(struct Vehicle &, struct outVector &, int t); -void write2CSV(struct outVector &); +void write2CSV(struct outVector &, struct Vehicle &); double derivative(double x2, double x1, double dt); double integral(double x2, double x1, double dt); @@ -40,7 +40,7 @@ bool sim(struct Vehicle &State, struct Vehicle &PrevState) { t++; } while ((State.z > 0.0) || (State.thrust > 1.0)); - write2CSV(stateVector); + write2CSV(stateVector, State); bool returnValue; @@ -330,7 +330,7 @@ void state2vec(Vehicle &State, outVector &stateVector, int t) { stateVector.thrustFiring[t] = State.thrustFiring; } -void write2CSV(outVector &stateVector) { +void write2CSV(outVector &stateVector, Vehicle &State) { // Deleting any previous output file if (remove("simOut.csv") != 0) @@ -351,7 +351,7 @@ void write2CSV(outVector &stateVector) { std::cout << "Writing to csv...\n"; // writing to output file - for (int t = 0; t < stateVector.x.size(); t++) { + for (int t = 0; t < State.simTime; t++) { outfile << t << ", "; outfile << stateVector.x[t] << ", ";