Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1926 → Rev 1927

/branches/dongfang_FC_fixedwing/flight.c
156,23 → 156,13
/************************************************************************/
/* Stick signals are positive and gyros are negative... */
/************************************************************************/
IPart[PITCH] = controlIntegrals[CONTROL_ELEVATOR] - angle[PITCH];
if (IPart[PITCH] > PITCHROLLOVER180) IPart[PITCH] -= PITCHROLLOVER360;
else if (IPart[PITCH] <= -PITCHROLLOVER180) IPart[PITCH] += PITCHROLLOVER360;
if (IPart[PITCH] > HH_RANGE) IPart[PITCH] = HH_RANGE;
else if (IPart[PITCH] < -HH_RANGE) IPart[PITCH] = -HH_RANGE;
 
IPart[ROLL] = controlIntegrals[CONTROL_AILERONS] - angle[ROLL];
if (IPart[ROLL] > PITCHROLLOVER180) IPart[ROLL] -= PITCHROLLOVER360;
else if (IPart[ROLL] <= -PITCHROLLOVER180) IPart[ROLL] += PITCHROLLOVER360;
if (IPart[ROLL] > HH_RANGE) IPart[ROLL] = HH_RANGE;
else if (IPart[ROLL] < -HH_RANGE) IPart[ROLL] = -HH_RANGE;
 
IPart[PITCH] = error[PITCH]; // * some factor configurable.
IPart[ROLL] = error[ROLL];
// TODO: Add ipart. Or add/subtract depending, not sure.
term[PITCH] = control[CONTROL_ELEVATOR] + (staticParams.ControlSigns & 1 ? PDPart[PITCH] : -PDPart[PITCH]);
term[ROLL] = control[CONTROL_AILERONS] + (staticParams.ControlSigns & 2 ? PDPart[ROLL] : -PDPart[ROLL]);
yawTerm = control[CONTROL_RUDDER] + (staticParams.ControlSigns & 4 ? PDPartYaw : -PDPartYaw);
 
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Universal Mixer
// Each (pitch, roll, throttle, yaw) term is in the range [0..255 * CONTROL_SCALING].
210,7 → 200,7
debugDataTimer = 24; // update debug outputs at 488 / 24 = 20.3 Hz.
DebugOut.Analog[0] = (10 * angle[PITCH]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[1] = (10 * angle[ROLL]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[2] = yawGyroHeading / GYRO_DEG_FACTOR_YAW;
DebugOut.Analog[2] = angle[YAW] / GYRO_DEG_FACTOR_YAW;
 
DebugOut.Analog[6] = pitchPFactor;
DebugOut.Analog[7] = rollPFactor;
219,8 → 209,8
DebugOut.Analog[10] = rollDFactor;
DebugOut.Analog[11] = yawDFactor;
 
DebugOut.Analog[18] = (10 * controlIntegrals[CONTROL_ELEVATOR]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[19] = (10 * controlIntegrals[CONTROL_AILERONS]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[18] = (10 * error[PITCH]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[19] = (10 * error[ROLL]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[22] = (10 * IPart[PITCH]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
DebugOut.Analog[23] = (10 * IPart[ROLL]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
}