private void Starttakeoff_Click(object sender, RoutedEventArgs e) { DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).StartTakeoffAsync(); GimbalAngleRotation camera_angle = new GimbalAngleRotation(); camera_angle.mode = GimbalAngleRotationMode.ABSOLUTE_ANGLE; camera_angle.pitch = -90; camera_angle.pitchIgnored = false; camera_angle.rollIgnored = true; camera_angle.yawIgnored = true; camera_angle.duration = 1; DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).RotateByAngleAsync(camera_angle); //var pos0 = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GetAircraftLocationAsync(); //x0 = pos0.Result.value.Value.latitude; //y0 = pos0.Result.value.Value.longitude; var z0 = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GetAltitudeAsync(); System.Diagnostics.Debug.WriteLine("z0:{0}", z0); }
private async void Grid_KeyDown(object sender, KeyRoutedEventArgs e) { switch (e.Key) { case Windows.System.VirtualKey.W: { throttle += 0.02f; if (throttle > 0.5f) { throttle = 0.5f; } break; } case Windows.System.VirtualKey.S: { throttle -= 0.02f; if (throttle < -0.5f) { throttle = -0.5f; } break; } case Windows.System.VirtualKey.A: { yaw -= 0.05f; if (yaw > 0.5f) { yaw = 0.5f; } break; } case Windows.System.VirtualKey.D: { yaw += 0.05f; if (yaw < -0.5f) { yaw = -0.5f; } break; } case Windows.System.VirtualKey.I: { pitch += 0.05f; if (pitch > 0.5) { pitch = 0.5f; } break; } case Windows.System.VirtualKey.K: { pitch -= 0.05f; if (pitch < -0.5f) { pitch = -0.5f; } break; } case Windows.System.VirtualKey.J: { roll -= 0.05f; if (roll < -0.5f) { roll = -0.5f; } break; } case Windows.System.VirtualKey.L: { roll += 0.05f; if (roll > 0.5) { roll = 0.5f; } break; } case Windows.System.VirtualKey.Number0: { GimbalAngleRotation rotation = new GimbalAngleRotation() { mode = GimbalAngleRotationMode.RELATIVE_ANGLE, pitch = 45, roll = 45, yaw = 45, pitchIgnored = false, yawIgnored = false, rollIgnored = false, duration = 0.5 }; System.Diagnostics.Debug.Write("pitch = 45\n"); // Defined somewhere else var gimbalHandler = DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0); //angle var gimbalRotation = new GimbalAngleRotation(); gimbalRotation.pitch = 45; gimbalRotation.pitchIgnored = false; gimbalRotation.duration = 5; await gimbalHandler.RotateByAngleAsync(gimbalRotation); //Speed var gimbalRotation_speed = new GimbalSpeedRotation(); gimbalRotation_speed.pitch = 10; await gimbalHandler.RotateBySpeedAsync(gimbalRotation_speed); await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).RotateByAngleAsync(rotation); break; } case Windows.System.VirtualKey.P: { GimbalAngleRotation rotation = new GimbalAngleRotation() { mode = GimbalAngleRotationMode.RELATIVE_ANGLE, pitch = 45, roll = 45, yaw = 45, pitchIgnored = false, yawIgnored = false, rollIgnored = false, duration = 0.5 }; System.Diagnostics.Debug.Write("pitch = 45\n"); // Defined somewhere else var gimbalHandler = DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0); //Speed var gimbalRotation_speed = new GimbalSpeedRotation(); gimbalRotation_speed.pitch = -10; await gimbalHandler.RotateBySpeedAsync(gimbalRotation_speed); await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).RotateByAngleAsync(rotation); break; } } try { if (DJISDKManager.Instance != null) { DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(throttle, yaw, pitch, roll); } } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err); } }