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:
parent
b9c2e7fb35
commit
717bb92678
@ -31,8 +31,8 @@ double loadCellCalibrate(HX711 loadCell) {
|
||||
}
|
||||
|
||||
void update_LoadCells(LoadCells &loadCells) {
|
||||
loadCells.lc0Val = loadCells.lc0.read();
|
||||
loadCells.lc1Val = loadCells.lc1.read();
|
||||
loadCells.lc2Val = loadCells.lc2.read();
|
||||
loadCells.lc3Val = loadCells.lc3.read();
|
||||
loadCells.lc0Val = loadCells.lc0.read() - loadCells.lc0Cal;
|
||||
loadCells.lc1Val = loadCells.lc1.read() - loadCells.lc1Cal;
|
||||
loadCells.lc2Val = loadCells.lc2.read() - loadCells.lc2Cal;
|
||||
loadCells.lc3Val = loadCells.lc3.read() - loadCells.lc3Cal;
|
||||
}
|
@ -22,7 +22,7 @@ struct Vehicle {
|
||||
double thrust, burnElapsed, burnStart;
|
||||
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 I11, I22, I33;
|
||||
|
@ -97,19 +97,22 @@ void processTVC(Vehicle &State, LoadCells &loadCells) {
|
||||
if (State.time == 0) {
|
||||
Serial.println("WARNING: processTVC not implemented for TEENSY");
|
||||
}
|
||||
|
||||
double r = 3.0;
|
||||
double R = 5.0;
|
||||
// Vector math to aqcuire thrust vector components
|
||||
// PLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER
|
||||
// PLACEHOLDERPLACEHOLDER PLACEHOLDERPLACEHOLDER PLACEHOLDER
|
||||
State.Fx = loadCells.lc1Val + loadCells.lc2Val;
|
||||
State.Fy = loadCells.lc0Val + loadCells.lc3Val;
|
||||
State.Fz = sqrt(pow(State.thrust, 2) - pow(State.Fx, 2) - pow(State.Fy, 2)) +
|
||||
(State.mass * g);
|
||||
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;
|
||||
|
||||
// Calculate moment created by Fx and Fy
|
||||
State.momentX = State.Fx * State.momentArm;
|
||||
State.momentY = State.Fy * State.momentArm;
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user