Advertisement
Bartosz_Popielarczyk

Untitled

Jul 26th, 2022
1,194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)WaypointMission:(CLLocation*)WPLoca
  2. {
  3.     float VirtualStickBearing = [self getHeadingForDirectionFromCoordinate:self.aircraftLocation.coordinate toCoordinate:WPLoca.coordinate];
  4.     float VirtualStickDistance = [self.aircraftLocation distanceFromLocation:WPLoca];
  5.     double VirtualStickAltitudeDifference = ABS(round(self.aircraftAltitude) - WPLoca.altitude);
  6.     NSLog(@"Current distance: %f to coord: %f , %f", VirtualStickDistance, WPLoca.coordinate.latitude, WPLoca.coordinate.longitude);
  7.     if (VirtualStickAltitudeDifference > 1)
  8.     {
  9.         self.mYaw = VirtualStickBearing;
  10.     }
  11.     else if (ABS(self.aircraftAttitude.yaw - VirtualStickBearing)>5)
  12.     {
  13.         self.mYaw = VirtualStickBearing;
  14.     }
  15.     else if (VirtualStickDistance > 60)
  16.     {
  17.         self.mYaw = VirtualStickBearing;
  18.         self.mXVelocity = 4.0;
  19.     }
  20.     else if (VirtualStickDistance > 2 && VirtualStickDistance <= 60)
  21.     {
  22.         self.mYaw = VirtualStickBearing;
  23.         self.mXVelocity = MIN(VirtualStickDistance/2, 4.0);
  24.     }
  25.     else{
  26.         self.mYaw = VirtualStickBearing;
  27.         self.mXVelocity = 0;
  28.         self.index = self.index + 1;
  29.     }
  30.     [self updateVirtualStick];
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement