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:
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,40 +356,42 @@ 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
|
||||||
for (int t = 0; t < State.simTime; t += State.stepSize) {
|
for (int t = 0; t < State.simTime; t += State.stepSize) {
|
||||||
outfile << t << ", ";
|
outfile << t << ", ";
|
||||||
|
|
||||||
outfile << stateVector.x[t] << ", ";
|
outfile << stateVector.x[t] << ",";
|
||||||
outfile << stateVector.y[t] << ", ";
|
outfile << stateVector.y[t] << ",";
|
||||||
outfile << stateVector.z[t] << ", ";
|
outfile << stateVector.z[t] << ",";
|
||||||
|
|
||||||
outfile << stateVector.vx[t] << ", ";
|
outfile << stateVector.vx[t] << ",";
|
||||||
outfile << stateVector.vy[t] << ", ";
|
outfile << stateVector.vy[t] << ",";
|
||||||
outfile << stateVector.vz[t] << ", ";
|
outfile << stateVector.vz[t] << ",";
|
||||||
|
|
||||||
outfile << stateVector.ax[t] << ", ";
|
outfile << stateVector.ax[t] << ",";
|
||||||
outfile << stateVector.ay[t] << ", ";
|
outfile << stateVector.ay[t] << ",";
|
||||||
outfile << stateVector.az[t] << ", ";
|
outfile << stateVector.az[t] << ",";
|
||||||
|
|
||||||
outfile << stateVector.yaw[t] * 180 / M_PI << ", ";
|
outfile << stateVector.yaw[t] * 180 / M_PI << ",";
|
||||||
outfile << stateVector.pitch[t] * 180 / M_PI << ", ";
|
outfile << stateVector.pitch[t] * 180 / M_PI << ",";
|
||||||
outfile << stateVector.roll[t] * 180 / M_PI << ", ";
|
outfile << stateVector.roll[t] * 180 / M_PI << ",";
|
||||||
|
|
||||||
outfile << stateVector.yawdot[t] * 180 / M_PI << ", ";
|
outfile << stateVector.yawdot[t] * 180 / M_PI << ",";
|
||||||
outfile << stateVector.pitchdot[t] * 180 / M_PI << ", ";
|
outfile << stateVector.pitchdot[t] * 180 / M_PI << ",";
|
||||||
outfile << stateVector.rolldot[t] * 180 / M_PI << ", ";
|
outfile << stateVector.rolldot[t] * 180 / M_PI << ",";
|
||||||
|
|
||||||
outfile << stateVector.servo1[t] << ", ";
|
outfile << stateVector.servo1[t] << ",";
|
||||||
outfile << stateVector.servo2[t] << ", ";
|
outfile << stateVector.servo2[t] << ",";
|
||||||
|
|
||||||
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