Advertisement
Bartosz_Popielarczyk

Untitled

Jul 26th, 2022
1,373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)WaypointVirtualStick
  2. {
  3.     CLLocation* WpLoca = self.WPLocations[self.index];
  4.     if (self.index < [self.WPLocations count])
  5.     {
  6.         NSLog(@"Current waypoint: %d", self.index);
  7.         [self WaypointMission:WpLoca];
  8.     }else{
  9.         [self.timeVS invalidate];
  10.         // self.mYaw = VirtualStickBearing;
  11.         self.mXVelocity = 0;
  12.         WeakRef(target);
  13.         [self.flightController setVirtualStickModeEnabled:NO withCompletion:^(NSError * _Nullable error) {
  14.             WeakReturn(target);
  15.             if (error){
  16.                 NSLog(@"Exit Virtual Stick False!");
  17.             } else{
  18.                 NSLog(@"Exit Virtual Stick Successed!");
  19.             }
  20.         }];
  21.         [self.flightController setIsVirtualStickAdvancedModeEnabled:NO];
  22.     }
  23.    
  24.  
  25. }
  26.  
  27.  
  28. - (IBAction)onFly:(id)sender
  29. {
  30.     self.mXVelocity = 0;
  31.     self.mYaw = 0;
  32.     self.mThrottle = self.aircraftLocation.altitude;
  33.    
  34.    
  35.     self.WPLocations = [[NSArray alloc] initWithObjects:(CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40561, 16.94785) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40553, 16.94816) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40542, 16.94791) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40524, 16.94793) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40536, 16.94768) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40523, 16.94742) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40544, 16.94745) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40561, 16.94716) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40561, 16.94751) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], (CLLocation*)[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(52.40577, 16.9477) altitude:self.aircraftLocation.altitude horizontalAccuracy:200.0 verticalAccuracy:200.0 timestamp:[NSDate date]], nil];
  36.  
  37.  
  38.     self.timeVS = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(WaypointVirtualStick) userInfo:nil repeats:YES];
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement