mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 23:26:43 +00:00
resolved #8
This commit is contained in:
parent
67917edb90
commit
9f48608518
@ -20,6 +20,9 @@ struct Vehicle {
|
|||||||
double burntime;
|
double burntime;
|
||||||
double burnVelocity;
|
double burnVelocity;
|
||||||
double thrust, burnElapsed, burnStart;
|
double thrust, burnElapsed, burnStart;
|
||||||
|
bool thrustFiring = false;
|
||||||
|
;
|
||||||
|
|
||||||
double LQRx, LQRy, Fx, Fy, Fz;
|
double LQRx, LQRy, Fx, Fy, Fz;
|
||||||
double momentX, momentY, momentZ;
|
double momentX, momentY, momentZ;
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ struct outVector {
|
|||||||
|
|
||||||
std::vector<double> servo1 = std::vector<double>(length, 0.0);
|
std::vector<double> servo1 = std::vector<double>(length, 0.0);
|
||||||
std::vector<double> servo2 = std::vector<double>(length, 0.0);
|
std::vector<double> servo2 = std::vector<double>(length, 0.0);
|
||||||
|
|
||||||
|
std::vector<bool> thrustFiring = std::vector<bool>(length, 0.0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -106,10 +106,10 @@ void thrustSelection(Vehicle &State, int t) {
|
|||||||
else
|
else
|
||||||
State.burnElapsed = 2000; // arbitrary number to ensure we don't burn
|
State.burnElapsed = 2000; // arbitrary number to ensure we don't burn
|
||||||
|
|
||||||
if ((State.burnElapsed > 0.147) && (State.burnElapsed < 0.420))
|
if ((State.burnElapsed > 0.147) && (State.burnElapsed < 0.420)) {
|
||||||
|
State.thrustFiring = true;
|
||||||
State.thrust = 65.165 * State.burnElapsed - 2.3921;
|
State.thrust = 65.165 * State.burnElapsed - 2.3921;
|
||||||
|
} else if ((State.burnElapsed > 0.419) && (State.burnElapsed < 3.383))
|
||||||
else if ((State.burnElapsed > 0.419) && (State.burnElapsed < 3.383))
|
|
||||||
State.thrust = 0.8932 * pow(State.burnElapsed, 6) -
|
State.thrust = 0.8932 * pow(State.burnElapsed, 6) -
|
||||||
11.609 * pow(State.burnElapsed, 5) +
|
11.609 * pow(State.burnElapsed, 5) +
|
||||||
60.739 * pow(State.burnElapsed, 4) -
|
60.739 * pow(State.burnElapsed, 4) -
|
||||||
@ -119,6 +119,9 @@ void thrustSelection(Vehicle &State, int t) {
|
|||||||
|
|
||||||
else if ((State.burnElapsed > 3.382) && (State.burnElapsed < 3.46))
|
else if ((State.burnElapsed > 3.382) && (State.burnElapsed < 3.46))
|
||||||
State.thrust = -195.78 * State.burnElapsed + 675.11;
|
State.thrust = -195.78 * State.burnElapsed + 675.11;
|
||||||
|
|
||||||
|
if (State.burnElapsed > 3.45)
|
||||||
|
State.thrustFiring = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lqrCalc(Vehicle &State) {
|
void lqrCalc(Vehicle &State) {
|
||||||
@ -323,6 +326,8 @@ void state2vec(Vehicle &State, outVector &stateVector, int t) {
|
|||||||
|
|
||||||
stateVector.servo1[t] = State.xServoDegs;
|
stateVector.servo1[t] = State.xServoDegs;
|
||||||
stateVector.servo2[t] = State.yServoDegs;
|
stateVector.servo2[t] = State.yServoDegs;
|
||||||
|
|
||||||
|
stateVector.thrustFiring[t] = State.thrustFiring;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write2CSV(outVector &stateVector) {
|
void write2CSV(outVector &stateVector) {
|
||||||
@ -340,7 +345,7 @@ void write2CSV(outVector &stateVector) {
|
|||||||
// Output file header. These are the variables that we output - useful for
|
// Output file header. These are the variables that we output - useful for
|
||||||
// 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"
|
"pitchdot, rolldot, Servo1, Servo2, thrustFiring"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::cout << "Writing to csv...\n";
|
std::cout << "Writing to csv...\n";
|
||||||
@ -370,7 +375,9 @@ void write2CSV(outVector &stateVector) {
|
|||||||
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] << std::endl;
|
outfile << stateVector.servo2[t] << ", ";
|
||||||
|
|
||||||
|
outfile << stateVector.thrustFiring[t] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user