mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 07:06:51 +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> PIDy = std::vector<double>(length, 0.0);
|
||||
|
||||
std::vector<double> thrust = std::vector<double>(length, 0.0);
|
||||
};
|
||||
|
||||
#endif
|
@ -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,40 +356,42 @@ 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
|
||||
for (int t = 0; t < State.simTime; t += State.stepSize) {
|
||||
outfile << t << ", ";
|
||||
|
||||
outfile << stateVector.x[t] << ", ";
|
||||
outfile << stateVector.y[t] << ", ";
|
||||
outfile << stateVector.z[t] << ", ";
|
||||
outfile << stateVector.x[t] << ",";
|
||||
outfile << stateVector.y[t] << ",";
|
||||
outfile << stateVector.z[t] << ",";
|
||||
|
||||
outfile << stateVector.vx[t] << ", ";
|
||||
outfile << stateVector.vy[t] << ", ";
|
||||
outfile << stateVector.vz[t] << ", ";
|
||||
outfile << stateVector.vx[t] << ",";
|
||||
outfile << stateVector.vy[t] << ",";
|
||||
outfile << stateVector.vz[t] << ",";
|
||||
|
||||
outfile << stateVector.ax[t] << ", ";
|
||||
outfile << stateVector.ay[t] << ", ";
|
||||
outfile << stateVector.az[t] << ", ";
|
||||
outfile << stateVector.ax[t] << ",";
|
||||
outfile << stateVector.ay[t] << ",";
|
||||
outfile << stateVector.az[t] << ",";
|
||||
|
||||
outfile << stateVector.yaw[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.pitch[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.roll[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.yaw[t] * 180 / M_PI << ",";
|
||||
outfile << stateVector.pitch[t] * 180 / M_PI << ",";
|
||||
outfile << stateVector.roll[t] * 180 / M_PI << ",";
|
||||
|
||||
outfile << stateVector.yawdot[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.pitchdot[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.rolldot[t] * 180 / M_PI << ", ";
|
||||
outfile << stateVector.yawdot[t] * 180 / M_PI << ",";
|
||||
outfile << stateVector.pitchdot[t] * 180 / M_PI << ",";
|
||||
outfile << stateVector.rolldot[t] * 180 / M_PI << ",";
|
||||
|
||||
outfile << stateVector.servo1[t] << ", ";
|
||||
outfile << stateVector.servo2[t] << ", ";
|
||||
outfile << stateVector.servo1[t] << ",";
|
||||
outfile << stateVector.servo2[t] << ",";
|
||||
|
||||
outfile << stateVector.thrustFiring[t] << ", ";
|
||||
outfile << stateVector.thrustFiring[t] << ",";
|
||||
|
||||
outfile << stateVector.PIDx[t] << ", ";
|
||||
outfile << stateVector.PIDy[t] << std::endl;
|
||||
outfile << stateVector.PIDx[t] << ",";
|
||||
outfile << stateVector.PIDy[t] << ",";
|
||||
|
||||
outfile << stateVector.thrust[t] << std::endl;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user