mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 15:17:23 +00:00
fixed size of csv file
This commit is contained in:
parent
07d330c904
commit
4322e52a30
@ -3,7 +3,6 @@
|
|||||||
#ifndef OUTVECTOR_H
|
#ifndef OUTVECTOR_H
|
||||||
#define OUTVECTOR_H
|
#define OUTVECTOR_H
|
||||||
|
|
||||||
|
|
||||||
struct outVector {
|
struct outVector {
|
||||||
int length = 10000; // current sim runs ~5000 steps, x2 just in case
|
int length = 10000; // current sim runs ~5000 steps, x2 just in case
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ void lqrCalc(struct Vehicle &);
|
|||||||
void TVC(struct Vehicle &);
|
void TVC(struct Vehicle &);
|
||||||
void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t);
|
void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t);
|
||||||
void state2vec(struct Vehicle &, struct outVector &, 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 derivative(double x2, double x1, double dt);
|
||||||
double integral(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++;
|
t++;
|
||||||
} while ((State.z > 0.0) || (State.thrust > 1.0));
|
} while ((State.z > 0.0) || (State.thrust > 1.0));
|
||||||
|
|
||||||
write2CSV(stateVector);
|
write2CSV(stateVector, State);
|
||||||
|
|
||||||
bool returnValue;
|
bool returnValue;
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ void state2vec(Vehicle &State, outVector &stateVector, int t) {
|
|||||||
stateVector.thrustFiring[t] = State.thrustFiring;
|
stateVector.thrustFiring[t] = State.thrustFiring;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write2CSV(outVector &stateVector) {
|
void write2CSV(outVector &stateVector, Vehicle &State) {
|
||||||
|
|
||||||
// Deleting any previous output file
|
// Deleting any previous output file
|
||||||
if (remove("simOut.csv") != 0)
|
if (remove("simOut.csv") != 0)
|
||||||
@ -351,7 +351,7 @@ void write2CSV(outVector &stateVector) {
|
|||||||
std::cout << "Writing to csv...\n";
|
std::cout << "Writing to csv...\n";
|
||||||
|
|
||||||
// writing to output file
|
// writing to output file
|
||||||
for (int t = 0; t < stateVector.x.size(); t++) {
|
for (int t = 0; t < State.simTime; t++) {
|
||||||
outfile << t << ", ";
|
outfile << t << ", ";
|
||||||
|
|
||||||
outfile << stateVector.x[t] << ", ";
|
outfile << stateVector.x[t] << ", ";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user