1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-06-16 15:17:23 +00:00

Added thrust logging, deleted deriv column along with spaces in csv file

This commit is contained in:
bpmcgeeney 2021-10-15 13:04:46 -07:00
parent 016ddc1261
commit 2f4a9044ef
2 changed files with 29 additions and 23 deletions

View File

@ -33,6 +33,8 @@ struct outVector {
std::vector<double> PIDx = std::vector<double>(length, 0.0);
std::vector<double> PIDy = std::vector<double>(length, 0.0);
std::vector<double> thrust = std::vector<double>(length, 0.0);
};
#endif

View File

@ -10,8 +10,8 @@ void TVC(struct Vehicle &, struct Vehicle &);
void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t);
void state2vec(struct Vehicle &, struct Vehicle &, struct outVector &, int t);
void write2CSV(struct outVector &, struct Vehicle &);
double derivative(double x2, double x1, double dt);
double integral(double x2, double x1, double dt);
double derivative(double current, double previous, double step);
double integral(double currentChange, double prevValue, double dt);
double limit(double value, double upr, double lwr);
// Any parameters that are constants should be declared here instead of
@ -334,6 +334,8 @@ void state2vec(Vehicle &State, Vehicle &PrevState, outVector &stateVector,
stateVector.PIDx[t] = State.PIDx;
stateVector.PIDy[t] = State.PIDy;
stateVector.thrust[t] = State.thrust;
// Set "prev" values for next timestep
PrevState = State;
}
@ -354,7 +356,7 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
// debugging
outfile << "t, x, y, z, vx, vy, vz, ax, ay, az, yaw, pitch, roll, yawdot, "
"pitchdot, rolldot, Servo1, Servo2, thrustFiring, PIDx, PIDy, "
"thrust, deriv"
"thrust"
<< std::endl;
// writing to output file
@ -387,7 +389,9 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
outfile << stateVector.thrustFiring[t] << ",";
outfile << stateVector.PIDx[t] << ",";
outfile << stateVector.PIDy[t] << std::endl;
outfile << stateVector.PIDy[t] << ",";
outfile << stateVector.thrust[t] << std::endl;
}
outfile.close();