Subversion Repositories FlightCtrl

Rev

Rev 966 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 966 Rev 988
Line 144... Line 144...
144
  }
144
  }
Line 145... Line 145...
145
 
145
 
146
  /* Set Hold Position */
146
  /* Set Hold Position */
147
  if ((actualPos.state > 2) &&
147
  if ((actualPos.state > 2) &&
148
    ((Override == 1) ||
148
    ((Override == 1) ||
149
    (SwitchPos ==  2) )) /* Update the hold position in case we are in target mode */
149
    (SwitchPos == 2) )) /* Update the hold position in case we are in target mode */
150
  {
150
  {
151
    holdPos.north = actualPos.north;
151
    holdPos.north = actualPos.north;
152
    holdPos.east = actualPos.east;
152
    holdPos.east = actualPos.east;
153
    holdPos.altitude = actualPos.altitude ;
153
    holdPos.altitude = actualPos.altitude ;
Line 202... Line 202...
202
 
202
 
203
  /* Determine Offset from nominal Position */
203
  /* Determine Offset from nominal Position */
204
  if (actualPos.state > 2 )
204
  if (actualPos.state > 2 )
205
  {
205
  {
206
    if ((SwitchPos ==  2) &&
206
    if ((SwitchPos ==  2) &&
207
    (targetPosValid == 1) &&
207
      (targetPosValid == 1) &&
208
        (RemoteLinkLost == 0) &&
208
      (RemoteLinkLost == 0) &&
209
        (Override == 0))
209
      (Override == 0))
210
    {  /* determine distance from target position */
210
    {  /* determine distance from target position */
211
      distanceNS = actualPos.north - targetPos.north; //  in 0.1m
211
      distanceNS = actualPos.north - targetPos.north; //  in 0.1m
212
      distanceEW = actualPos.east - targetPos.east; // in 0.1m
212
      distanceEW = actualPos.east - targetPos.east; // in 0.1m
213
      velocityNS = actualPos.velNorth; // in 0.1m/s
213
      velocityNS = actualPos.velNorth; // in 0.1m/s
214
      velocityEW = actualPos.velEast; // in 0.1m/s
214
      velocityEW = actualPos.velEast; // in 0.1m/s
215
      maxDistance = sqrt(distanceNS * distanceNS + distanceEW * distanceEW);
215
      maxDistance = sqrt(distanceNS * distanceNS + distanceEW * distanceEW);
216
    }
216
    }
217
    else if ((SwitchPos ==  1)&&
217
    else if ((SwitchPos ==  1)&&
218
      (holdPosValid == 1) &&
218
      (holdPosValid == 1) &&
219
  (RemoteLinkLost == 0) &&
219
      (RemoteLinkLost == 0) &&
220
          (Override == 0))
220
      (Override == 0))
221
    {  /* determine distance from hold position */
221
    {  /* determine distance from hold position */
222
      distanceNS = actualPos.north - holdPos.north; //  in 0.1m
222
      distanceNS = actualPos.north - holdPos.north; //  in 0.1m
223
      distanceEW = actualPos.east - holdPos.east; // in 0.1m
223
      distanceEW = actualPos.east - holdPos.east; // in 0.1m
224
      velocityNS = actualPos.velNorth; // in 0.1m/s
224
      velocityNS = actualPos.velNorth; // in 0.1m/s
Line 234... Line 234...
234
      velocityEW = actualPos.velEast; // in 0.1m/s
234
      velocityEW = actualPos.velEast; // in 0.1m/s
235
      maxDistance = sqrt(distanceNS * distanceNS + distanceEW * distanceEW);
235
      maxDistance = sqrt(distanceNS * distanceNS + distanceEW * distanceEW);
236
    }
236
    }
237
    else
237
    else
238
    {
238
    {
239
        distanceNS = 0.0F; //  in 0.1m
239
      distanceNS = 0.0F; //  in 0.1m
240
        distanceEW = 0.0F; // in 0.1m
240
      distanceEW = 0.0F; // in 0.1m
241
        velocityNS = 0.0F; // in 0.1m/s
241
      velocityNS = 0.0F; // in 0.1m/s
242
        velocityEW = 0.0F; // in 0.1m/s
242
      velocityEW = 0.0F; // in 0.1m/s
243
        maxDistance = 0.0F;
243
      maxDistance = 0.0F;
244
        GPSTrackingCycles = 0;
244
      GPSTrackingCycles = 0;
245
    }
245
    }
Line 246... Line 246...
246
   
246
   
247
    /* Limit GPS_Nick to 25 */
247
    /* Limit GPS_Nick to 25 */
248
    nick_gain_p = (long) MAX(-maxGainPos, MIN(maxGainPos, ((distanceNS* max_p)/50)));  //m
248
    nick_gain_p = (long) MAX(-maxGainPos, MIN(maxGainPos, ((distanceNS* max_p)/50)));  //m