mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 23:26:43 +00:00
Added thrust logging, deleted deriv column along with spaces in csv file
This commit is contained in:
parent
016ddc1261
commit
2f4a9044ef
@ -33,6 +33,8 @@ struct outVector {
|
|||||||
|
|
||||||
std::vector<double> PIDx = std::vector<double>(length, 0.0);
|
std::vector<double> PIDx = std::vector<double>(length, 0.0);
|
||||||
std::vector<double> PIDy = 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
|
#endif
|
@ -10,8 +10,8 @@ void TVC(struct Vehicle &, struct Vehicle &);
|
|||||||
void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t);
|
void vehicleDynamics(struct Vehicle &, struct Vehicle &, int t);
|
||||||
void state2vec(struct Vehicle &, struct Vehicle &, struct outVector &, int t);
|
void state2vec(struct Vehicle &, struct Vehicle &, struct outVector &, int t);
|
||||||
void write2CSV(struct outVector &, struct Vehicle &);
|
void write2CSV(struct outVector &, struct Vehicle &);
|
||||||
double derivative(double x2, double x1, double dt);
|
double derivative(double current, double previous, double step);
|
||||||
double integral(double x2, double x1, double dt);
|
double integral(double currentChange, double prevValue, double dt);
|
||||||
double limit(double value, double upr, double lwr);
|
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
|
||||||
@ -334,6 +334,8 @@ void state2vec(Vehicle &State, Vehicle &PrevState, outVector &stateVector,
|
|||||||
stateVector.PIDx[t] = State.PIDx;
|
stateVector.PIDx[t] = State.PIDx;
|
||||||
stateVector.PIDy[t] = State.PIDy;
|
stateVector.PIDy[t] = State.PIDy;
|
||||||
|
|
||||||
|
stateVector.thrust[t] = State.thrust;
|
||||||
|
|
||||||
// Set "prev" values for next timestep
|
// Set "prev" values for next timestep
|
||||||
PrevState = State;
|
PrevState = State;
|
||||||
}
|
}
|
||||||
@ -354,7 +356,7 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
|
|||||||
// debugging
|
// debugging
|
||||||
outfile << "t, x, y, z, vx, vy, vz, ax, ay, az, yaw, pitch, roll, yawdot, "
|
outfile << "t, x, y, z, vx, vy, vz, ax, ay, az, yaw, pitch, roll, yawdot, "
|
||||||
"pitchdot, rolldot, Servo1, Servo2, thrustFiring, PIDx, PIDy, "
|
"pitchdot, rolldot, Servo1, Servo2, thrustFiring, PIDx, PIDy, "
|
||||||
"thrust, deriv"
|
"thrust"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// writing to output file
|
// writing to output file
|
||||||
@ -387,7 +389,9 @@ void write2CSV(outVector &stateVector, Vehicle &State) {
|
|||||||
outfile << stateVector.thrustFiring[t] << ",";
|
outfile << stateVector.thrustFiring[t] << ",";
|
||||||
|
|
||||||
outfile << stateVector.PIDx[t] << ",";
|
outfile << stateVector.PIDx[t] << ",";
|
||||||
outfile << stateVector.PIDy[t] << std::endl;
|
outfile << stateVector.PIDy[t] << ",";
|
||||||
|
|
||||||
|
outfile << stateVector.thrust[t] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user