Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) setThrottle:(float)y andYaw:(float)x
- {
- self.mThrottle = y * -2;
- self.mYaw = x * 30;
- [self updateVirtualStick];
- }
- -(void) setXVelocity:(float)x andYVelocity:(float)y {
- self.mXVelocity = x * 15.0;
- self.mYVelocity = y * 15.0;
- [self updateVirtualStick];
- }
- -(void) updateVirtualStick
- {
- // In rollPitchVelocity mode, the pitch property in DJIVirtualStickFlightControlData represents the Y direction velocity.
- // The roll property represents the X direction velocity.
- DJIVirtualStickFlightControlData ctrlData = {0};
- ctrlData.pitch = self.mYVelocity;
- ctrlData.roll = self.mXVelocity;
- ctrlData.yaw = self.mYaw;
- ctrlData.verticalThrottle = self.mThrottle;
- DJIFlightController* fc = [DemoUtility fetchFlightController];
- WeakRef(target);
- if (fc && fc.isVirtualStickControlModeAvailable) {
- [fc sendVirtualStickFlightControlData:ctrlData withCompletion:^(NSError * _Nullable error) {
- WeakReturn(target);
- if (error) {
- NSLog(@"Send Control Data error!");
- }
- else
- {
- NSLog(@"Send Control Data succeeded!");
- }
- }];
- }
- else{
- NSLog(@"Virtual Stick Control Mode not Availabe!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement