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

start of readability changes

This commit is contained in:
Anson Biggs 2021-09-13 08:50:54 -07:00
parent e78a402861
commit badfef7a3f

View File

@ -1,23 +1,27 @@
#include "sVars.h"
void burnStartTimeCalc(struct sVars &, double g);
void burnStartTimeCalc(struct sVars &);
void thrustSelection(struct sVars &, int t);
void lqrCalc(struct sVars &);
void TVC(struct sVars &, double g);
void TVC(struct sVars &);
void vehicleDynamics(struct sVars &, int t);
void write2CSV(struct sVars &, std::fstream &outfile, int t);
double derivative(double x2, double x1, double dt);
double integral(double x2, double x1, double dt);
// Any parameters that are constants should be declared here instead of buried
// in code
float const dt = 0.001;
float const g = -9.81;
void sim(struct sVars &Vars) {
double g = -9.81;
// defining a few random values here cause I'm lazy
Vars.burnElapsed = 2000;
Vars.m = Vars.m0;
Vars.thrust_prev = 0;
burnStartTimeCalc(Vars, g);
burnStartTimeCalc(Vars);
// Deleting any previous output file
if (remove("simOut.csv") != 0)
@ -42,7 +46,7 @@ void sim(struct sVars &Vars) {
for (int t = 0; t < Vars.simTime; t++) {
thrustSelection(Vars, t);
lqrCalc(Vars);
TVC(Vars, g);
TVC(Vars);
vehicleDynamics(Vars, t);
write2CSV(Vars, outfile, t);
}
@ -50,10 +54,10 @@ void sim(struct sVars &Vars) {
outfile.close();
}
void burnStartTimeCalc(struct sVars &Vars, double g) {
void burnStartTimeCalc(struct sVars &Vars) {
double v = Vars.vz;
double h = 0;
double dt = 0.001;
double a, j, m, thrust;
for (double i = 0.148; i < 3.450; i = i + dt) {
@ -230,7 +234,7 @@ void lqrCalc(struct sVars &Vars) {
Vars.LQRy = -1 * Vars.thrust;
}
void TVC(struct sVars &Vars, double g) {
void TVC(struct sVars &Vars) {
if (Vars.thrust < 1) {
// Define forces and moments for t = 0
Vars.Fx = 0;