91,9 → 91,9 |
} |
|
// checks nick and roll sticks for manual control |
uint8_t GPS_isManuallyControlled(int16_t* naviSticks) { |
if (naviSticks[CONTROL_PITCH] < staticParams.naviStickThreshold |
&& naviSticks[CONTROL_ROLL] < staticParams.naviStickThreshold) |
uint8_t GPS_isManuallyControlled(int16_t* sticks) { |
if (sticks[CONTROL_PITCH] < staticParams.naviStickThreshold |
&& sticks[CONTROL_ROLL] < staticParams.naviStickThreshold) |
return 0; |
else |
return 1; |
101,9 → 101,8 |
|
// set given position to current gps position |
uint8_t GPS_setCurrPosition(GPS_Pos_t * pGPSPos) { |
uint8_t retval = 0; |
if (pGPSPos == NULL) |
return (retval); // bad pointer |
return 0; // bad pointer |
|
if (GPS_isSignalOK()) { // is GPS signal condition is fine |
pGPSPos->longitude = GPSInfo.longitude; |
110,27 → 109,24 |
pGPSPos->latitude = GPSInfo.latitude; |
pGPSPos->altitude = GPSInfo.altitude; |
pGPSPos->status = NEWDATA; |
retval = 1; |
return 1; |
} else { // bad GPS signal condition |
pGPSPos->status = INVALID; |
retval = 0; |
return 0; |
} |
return (retval); |
} |
|
// clear position |
uint8_t GPS_clearPosition(GPS_Pos_t * pGPSPos) { |
uint8_t retval = 0; |
if (pGPSPos == NULL) |
return retval; // bad pointer |
return 0; // bad pointer |
else { |
pGPSPos->longitude = 0; |
pGPSPos->latitude = 0; |
pGPSPos->altitude = 0; |
pGPSPos->status = INVALID; |
retval = 1; |
} |
return (retval); |
return 1; |
} |
|
// calculates the GPS control stick values from the deviation to target position |
140,8 → 136,7 |
static int32_t PID_Nick, PID_Roll; |
int32_t coscompass, sincompass; |
int32_t GPSPosDev_North, GPSPosDev_East; // Position deviation in cm |
int32_t P_North = 0, D_North = 0, P_East = 0, D_East = 0, I_North = 0, |
I_East = 0; |
int32_t P_North = 0, D_North = 0, P_East = 0, D_East = 0, I_North = 0, I_East = 0; |
int32_t PID_North = 0, PID_East = 0; |
static int32_t cos_target_latitude = 1; |
static int32_t GPSPosDevIntegral_North = 0, GPSPosDevIntegral_East = 0; |
149,10 → 144,8 |
|
// if GPS data and Compass are ok |
if (GPS_isSignalOK() && (magneticHeading >= 0)) { |
if (pTargetPos != NULL) // if there is a target position |
{ |
if (pTargetPos->status != INVALID) // and the position data are valid |
{ |
if (pTargetPos != NULL) { // if there is a target position |
if (pTargetPos->status != INVALID) { // and the position data are valid |
// if the target data are updated or the target pointer has changed |
if ((pTargetPos->status != PROCESSED) |
|| (pTargetPos != pLastTargetPos)) { |
160,7 → 153,7 |
GPSPosDevIntegral_North = 0; |
GPSPosDevIntegral_East = 0; |
// recalculate latitude projection |
cos_target_latitude = int_cos((int16_t) (pTargetPos->latitude / 10000000L)); |
cos_target_latitude = cos_360((int16_t) (pTargetPos->latitude / 10000000L)); |
// remember last target pointer |
pLastTargetPos = pTargetPos; |
// mark data as processed |
236,8 → 229,9 |
// in the flight.c. Therefore a positive north deviation/velocity should result in a positive |
// GPSStickNick and a positive east deviation/velocity should result in a negative GPSStickRoll. |
|
coscompass = int_cos(yawGyroHeading / GYRO_DEG_FACTOR_YAW); |
sincompass = int_sin(yawGyroHeading / GYRO_DEG_FACTOR_YAW); |
coscompass = cos_360(yawGyroHeading / GYRO_DEG_FACTOR_YAW); |
sincompass = sin_360(yawGyroHeading / GYRO_DEG_FACTOR_YAW); |
|
PID_Nick = (coscompass * PID_North + sincompass * PID_East) >> MATH_UNIT_FACTOR_LOG; |
PID_Roll = (sincompass * PID_North - coscompass * PID_East) >> MATH_UNIT_FACTOR_LOG; |
|
261,8 → 255,9 |
|
// store home position if start of flight flag is set |
if (MKFlags & MKFLAG_CALIBRATE) { |
MKFlags &= ~(MKFLAG_CALIBRATE); |
if (GPS_setCurrPosition(&homePosition)) |
beep(700); |
beep(500); |
} |
|
switch (GPSInfo.status) { |
360,5 → 355,8 |
GPSInfo.status = PROCESSED; |
break; |
} // eof GPSInfo.status |
|
debugOut.analog[11] = GPSInfo.satnum; |
} |
|
|