mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-08-17 02:24:50 +00:00
load cell integration
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
#include "LoadCells.h"
|
||||
#include "Vehicle.h"
|
||||
#include <Arduino.h>
|
||||
#include <SD.h>
|
||||
@@ -8,7 +7,7 @@ double loadCellCalibrate();
|
||||
void initFile();
|
||||
void thrustInfo(struct Vehicle &);
|
||||
void processTVC(struct Vehicle &);
|
||||
void write2CSV(struct Vehicle &, double a, double b, double c, double d);
|
||||
void write2CSV(struct Vehicle &);
|
||||
void printSimResults(struct Vehicle &);
|
||||
void teensyAbort();
|
||||
|
||||
@@ -94,7 +93,7 @@ void thrustInfo(Vehicle &State) {
|
||||
}
|
||||
}
|
||||
|
||||
void processTVC(Vehicle &State, LoadCells &loadCells) {
|
||||
void processTVC(Vehicle &State) {
|
||||
if (State.time == 0) {
|
||||
Serial.println("WARNING: processTVC not implemented for TEENSY");
|
||||
}
|
||||
@@ -103,10 +102,14 @@ void processTVC(Vehicle &State, LoadCells &loadCells) {
|
||||
// Vector math to aqcuire thrust vector components
|
||||
// PLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER
|
||||
// PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDER
|
||||
State.Fx = (loadCells.lc1Val - loadCells.lc2Val) * r / R;
|
||||
State.Fy = (loadCells.lc0Val - loadCells.lc3Val) * r / R;
|
||||
State.Fz =
|
||||
loadCells.lc0Val + loadCells.lc1Val + loadCells.lc2Val + loadCells.lc3Val;
|
||||
State.Fx = (State.lc1 - State.lc2) * r / R;
|
||||
State.Fy = (State.lc0 - State.lc3) * r / R;
|
||||
State.Fz = State.lc0 + State.lc1 + State.lc2 + State.lc3;
|
||||
|
||||
State.Fx = State.thrust * sin(State.xServoDegs * (M_PI / 180.0));
|
||||
State.Fy = State.thrust * sin(State.yServoDegs * (M_PI / 180.0));
|
||||
State.Fz = sqrt(pow(State.thrust, 2) - pow(State.Fx, 2) - pow(State.Fy, 2)) +
|
||||
(State.mass * g);
|
||||
|
||||
// Calculate moment created by Fx and Fy
|
||||
State.momentX = State.Fx * State.momentArm;
|
||||
@@ -116,7 +119,7 @@ void processTVC(Vehicle &State, LoadCells &loadCells) {
|
||||
State.F = sqrt(pow(State.Fx, 2) + pow(State.Fy, 2) + pow(State.Fz, 2));
|
||||
}
|
||||
|
||||
void write2CSV(Vehicle &State, LoadCells &loadCells) {
|
||||
void write2CSV(Vehicle &State) {
|
||||
dataFile.print(String(State.time, 5));
|
||||
dataFile.print(",");
|
||||
|
||||
@@ -168,13 +171,13 @@ void write2CSV(Vehicle &State, LoadCells &loadCells) {
|
||||
dataFile.print(String(State.stepDuration, 5));
|
||||
dataFile.print(",");
|
||||
|
||||
dataFile.print(String(loadCells.lc0Val, 5));
|
||||
dataFile.print(String(State.lc0, 5));
|
||||
dataFile.print(",");
|
||||
dataFile.print(String(loadCells.lc1Val, 5));
|
||||
dataFile.print(String(State.lc1, 5));
|
||||
dataFile.print(",");
|
||||
dataFile.print(String(loadCells.lc2Val, 5));
|
||||
dataFile.print(String(State.lc2, 5));
|
||||
dataFile.print(",");
|
||||
dataFile.print(String(loadCells.lc3Val, 5));
|
||||
dataFile.print(String(State.lc3, 5));
|
||||
|
||||
dataFile.print("\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user