mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-08-02 11:31:34 +00:00
Merge branch 'main' into '22-make-function-to-turn-test-stand-load-cells-into-thrust-vector'
# Conflicts: # .vscode/extensions.json # include/teensy.h # src/main.cpp
This commit is contained in:
27
src/main.cpp
27
src/main.cpp
@@ -10,6 +10,8 @@
|
||||
#include <vector>
|
||||
#elif defined(TEENSY)
|
||||
#include <Arduino.h>
|
||||
|
||||
int BUILTIN_LED = 13;
|
||||
unsigned long last;
|
||||
#endif
|
||||
|
||||
@@ -18,6 +20,7 @@ unsigned long last;
|
||||
|
||||
#if defined(NATIVE) || defined(_WIN32)
|
||||
#include "native.h"
|
||||
outVector stateVector;
|
||||
#elif defined(TEENSY)
|
||||
|
||||
#include "LoadCells.h"
|
||||
@@ -35,7 +38,6 @@ const int lc_data_3 = 3;
|
||||
|
||||
Vehicle State;
|
||||
Vehicle PrevState;
|
||||
outVector stateVector;
|
||||
|
||||
#if defined(NATIVE) || defined(_WIN32)
|
||||
void setup() {
|
||||
@@ -71,6 +73,8 @@ void setup() {
|
||||
|
||||
Serial.println("Load Cells Calibrated");
|
||||
delay(1000);
|
||||
initFile();
|
||||
delay(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -83,9 +87,11 @@ void loop() {
|
||||
processTVC(State);
|
||||
state2vec(State, PrevState, stateVector);
|
||||
|
||||
// Set "prev" values for next timestep
|
||||
PrevState = State;
|
||||
State.time += State.stepSize;
|
||||
|
||||
if (State.z < 0.0) {
|
||||
if ((State.z < 0.0) && (State.thrustFiring == 2)) {
|
||||
write2CSV(stateVector, State);
|
||||
printSimResults(State);
|
||||
init_Vehicle(State);
|
||||
@@ -93,6 +99,7 @@ void loop() {
|
||||
}
|
||||
#elif defined(TEENSY)
|
||||
void loop() {
|
||||
|
||||
last = millis();
|
||||
vehicleDynamics(State, PrevState);
|
||||
thrustInfo(State);
|
||||
@@ -103,14 +110,16 @@ void loop() {
|
||||
|
||||
State.time += State.stepSize;
|
||||
|
||||
if (State.z < 0.0) {
|
||||
write2CSV(stateVector, State);
|
||||
if ((State.z < 0.0) && (State.thrustFiring == 2)) {
|
||||
printSimResults(State);
|
||||
init_Vehicle(State);
|
||||
Serial.println("Last run duration:" + String(millis() - last + " ms"));
|
||||
Serial.println("Run duration:" + String(millis() - last) + " ms");
|
||||
|
||||
delay(1000);
|
||||
Serial.println("Restarting Sim");
|
||||
closeFile();
|
||||
delay(20000);
|
||||
|
||||
Serial.println("SUCCESS");
|
||||
Serial.println("Aborting Sim");
|
||||
teensyAbort();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -122,7 +131,7 @@ int main() {
|
||||
|
||||
do {
|
||||
loop();
|
||||
} while ((State.z > 0.0));
|
||||
} while ((State.z > 0.0) || (State.thrustFiring != 2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user