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

Update lc values to be calibrated and vector math

This commit is contained in:
Matthew Robinaugh 2021-11-13 11:32:42 -07:00
parent b9c2e7fb35
commit 717bb92678
3 changed files with 13 additions and 10 deletions

View File

@ -31,8 +31,8 @@ double loadCellCalibrate(HX711 loadCell) {
} }
void update_LoadCells(LoadCells &loadCells) { void update_LoadCells(LoadCells &loadCells) {
loadCells.lc0Val = loadCells.lc0.read(); loadCells.lc0Val = loadCells.lc0.read() - loadCells.lc0Cal;
loadCells.lc1Val = loadCells.lc1.read(); loadCells.lc1Val = loadCells.lc1.read() - loadCells.lc1Cal;
loadCells.lc2Val = loadCells.lc2.read(); loadCells.lc2Val = loadCells.lc2.read() - loadCells.lc2Cal;
loadCells.lc3Val = loadCells.lc3.read(); loadCells.lc3Val = loadCells.lc3.read() - loadCells.lc3Cal;
} }

View File

@ -22,7 +22,7 @@ struct Vehicle {
double thrust, burnElapsed, burnStart; double thrust, burnElapsed, burnStart;
int thrustFiring = 0; // 0: Pre-burn, 1: Mid-burn, 2: Post-burn int thrustFiring = 0; // 0: Pre-burn, 1: Mid-burn, 2: Post-burn
double PIDx, PIDy, Fx, Fy, Fz; double PIDx, PIDy, Fx, Fy, Fz, F;
double momentX, momentY, momentZ; double momentX, momentY, momentZ;
double I11, I22, I33; double I11, I22, I33;

View File

@ -97,19 +97,22 @@ void processTVC(Vehicle &State, LoadCells &loadCells) {
if (State.time == 0) { if (State.time == 0) {
Serial.println("WARNING: processTVC not implemented for TEENSY"); Serial.println("WARNING: processTVC not implemented for TEENSY");
} }
double r = 3.0;
double R = 5.0;
// Vector math to aqcuire thrust vector components // Vector math to aqcuire thrust vector components
// PLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER // PLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER
// PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDER // PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDER
State.Fx = loadCells.lc1Val + loadCells.lc2Val; State.Fx = (loadCells.lc1Val - loadCells.lc2Val) * r / R;
State.Fy = loadCells.lc0Val + loadCells.lc3Val; State.Fy = (loadCells.lc0Val - loadCells.lc3Val) * r / R;
State.Fz = sqrt(pow(State.thrust, 2) - pow(State.Fx, 2) - pow(State.Fy, 2)) + State.Fz =
(State.mass * g); loadCells.lc0Val + loadCells.lc1Val + loadCells.lc2Val + loadCells.lc3Val;
// Calculate moment created by Fx and Fy // Calculate moment created by Fx and Fy
State.momentX = State.Fx * State.momentArm; State.momentX = State.Fx * State.momentArm;
State.momentY = State.Fy * State.momentArm; State.momentY = State.Fy * State.momentArm;
State.momentZ = 0.0; State.momentZ = 0.0;
State.F = sqrt(pow(State.Fx, 2) + pow(State.Fy, 2) + pow(State.Fz, 2));
} }
void write2CSV(Vehicle &State, double a, double b, double c, double d) { void write2CSV(Vehicle &State, double a, double b, double c, double d) {