1
0
mirror of https://gitlab.com/lander-team/lander-cpp.git synced 2026-06-03 21:10:31 +00:00

code compiles and runs on teensy

This commit is contained in:
2021-10-28 21:53:12 -07:00
parent 7db2ab59f6
commit ed816f223a
3 changed files with 104 additions and 51 deletions
+46 -5
View File
@@ -1,5 +1,10 @@
#define M_PI 3.14159265359
#ifdef TEENSY
#endif
#include <Arduino.h>
unsigned long tic, toc = millis();
#include <cmath>
#include <fstream>
#include <iostream>
@@ -13,7 +18,7 @@
bool sim(struct Vehicle &);
int main() {
int run_simulation() {
Vehicle State;
Vehicle PrevState;
@@ -28,9 +33,9 @@ int main() {
State.vz = 0; // [m/s]
// Initial YPR
State.yaw = 10 * M_PI / 180; // [rad]
State.yaw = 10 * M_PI / 180; // [rad]
State.pitch = 5 * M_PI / 180; // [rad]
State.roll = 0 * M_PI / 180; // [rad]
State.roll = 0 * M_PI / 180; // [rad]
// Initial YPRdot
State.yawdot = 1 * M_PI / 180; // [rad/s]
@@ -38,7 +43,7 @@ int main() {
State.rolldot = 0 * M_PI / 180; // [rad/s]
// Servo Limitation
State.maxServo = 7; // [degs]
State.maxServo = 7; // [degs]
State.maxServoRate = 360; // [degs/sec]
// Vehicle Properties
@@ -64,5 +69,41 @@ int main() {
std::cout << std::endl << "Simulation Complete 🚀" << std::endl;
// ^^^
// 50% chance this makes Mattys linux crash
return 0;
return outcome;
}
#ifndef LED_ON
#define LED_ON (HIGH)
#endif
#ifndef LED_BUILTIN
#define LED_BUILTIN (13)
#endif
#ifndef LED
#define LED (LED_BUILTIN)
#endif
void setup() {
// initialize the digital pin as an output.
delay(10000);
pinMode(LED, OUTPUT);
Serial.begin(115200);
Serial.println("hello world!");
}
void loop() {
Serial.println("blink on");
digitalWrite(LED, LED_ON); // set the LED on
tic = millis();
run_simulation();
toc = millis();
Serial.println("SIM RESULT:");
Serial.println(toc - tic);
Serial.println("blink off");
digitalWrite(LED, !LED_ON); // set the LED off
delay(1000);
}