1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2025-07-25 23:51:35 +00:00

Make teensy compile

This commit is contained in:
2021-11-04 19:46:10 +00:00
parent ce4cbff8bd
commit b9ccfd110e
3 changed files with 127 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
#define M_PI 3.14159265359
#if defined(NATIVE) || defined(_WIN32)
#include <cmath>
#include <fstream>
#include <iostream>
@@ -7,6 +8,11 @@
#include <stdio.h>
#include <string>
#include <vector>
#elif defined(TEENSY)
#include <Arduino.h>
unsigned long last;
#endif
#include "Vehicle.h"
#include "sim.h"
@@ -30,16 +36,23 @@ void setup() {
}
#elif defined(TEENSY)
void setup() {
delay(1000);
init_Vehicle(State);
Serial.println("Simulated Vehicle Initalized");
delay(1000);
// Determine when to burn
burnStartTimeCalc(State);
Serial.println("Starting Height Calculated");
delay(1000);
loadCellCalibrate();
Serial.println("Load Cells Calibrated");
delay(1000);
}
#endif
#if defined(NATIVE) || defined(_WIN32)
void loop() {
vehicleDynamics(State, PrevState);
thrustInfo(State);
pidController(State, PrevState);
@@ -52,8 +65,32 @@ void loop() {
if (State.z < 0.0) {
write2CSV(stateVector, State);
printSimResults(State);
init_Vehicle(State);
}
}
#elif defined(TEENSY)
void loop() {
last = millis();
vehicleDynamics(State, PrevState);
thrustInfo(State);
pidController(State, PrevState);
TVC(State, PrevState);
processTVC(State);
// state2vec(State, PrevState, stateVector);
State.time += State.stepSize;
if (State.z < 0.0) {
write2CSV(stateVector, State);
printSimResults(State);
init_Vehicle(State);
Serial.println("Last run duration:" + String(millis() - last + " ms"));
delay(1000);
Serial.println("Restarting Sim");
}
}
#endif
#if defined(_WIN32) || defined(linux)
int main() {