internal void connectToDrone() { DroneControllerConfiguration droneControllerConfiguration = new DroneControllerConfiguration(); droneControllerConfiguration.EnableNavigationDataThread = false; droneControllerConfiguration.EnableVideoStreamThread = true; droneControllerConfiguration.EnableGPSStreamThread = false; droneControllerConfiguration.EnableATCommandThread = true; droneControllerConfiguration.EnableControlInfoThread = false; droneControllerConfiguration.EnableATCommandSimulation = false; droneControllerConfiguration.DroneIpAddress = IPBox.Text; droneController = null; // ensure null for creation (removed set = null in disconect) droneController = new DroneController.DroneController(droneControllerConfiguration); droneController.IsMoving = true; droneController.TraceNotificationLevel = TraceNotificationLevel.Verbose; droneController.OnNotifyTraceMessage += new EventHandler<TraceNotificationEventArgs>(droneController_OnNotifyTraceMessage); droneController.OnNotifyVideoMessage += new EventHandler<VideoNotificationEventArgs>(droneController_OnNotifyVideoMessage); droneController.OnNotifyGPSMessage += new EventHandler<GPSNotificationEventArgs>(droneController_OnNotifyGPSMessage); droneController.OnNotifyDroneInfoMessage += new EventHandler<DroneInfoNotificationEventArgs>(droneController_OnNotifyDroneInfoMessage); droneController.OnConnectionStatusChanged += new EventHandler<ConnectionStatusChangedEventArgs>(droneController_OnConnectionStatusChanged); droneController.Connect(); while (droneController.ConnectionStatus != ConnectionStatus.Open) Thread.Sleep(100); droneController.SetConfiguration("control:euler_angle_max", MathHelper.ToRadians((App.Current as App).Config.EulerAngleMax).ToString()); droneController.SetConfiguration("control:control_iphone_tilt", "1"); droneController.SetConfiguration("control:altitude_max", (App.Current as App).Config.MaxAltitude.ToString()); droneController.SetConfiguration("control:control_vz_max", (App.Current as App).Config.VerticalSpeed.ToString()); droneController.SetConfiguration("control:control_yaw", MathHelper.ToRadians(200).ToString()); verticalSpeed = 1.0f; yawSpeed = MathHelper.ToRadians((App.Current as App).Config.YawSpeed) / MathHelper.ToRadians(200); }
/// <summary> /// Initializes a new instance of the <see cref="DroneController"/> class. /// </summary> /// <param name="droneControllerConfiguration">The drone controller configuration.</param> public DroneController(DroneControllerConfiguration droneControllerConfiguration) { ControllerConfig = droneControllerConfiguration; DroneProxy = DroneProxy.Create(); #if Video VideoImage = new VideoImage(); VideoImage.ImageComplete += new EventHandler<ImageCompleteEventArgs>(VideoImage_ImageComplete); #endif DroneInfoNotificationEventArgs = new DroneInfoNotificationEventArgs(); DroneInfoTimer = new DispatcherTimer(); DroneInfoTimer.Interval = TimeSpan.FromTicks(Constants.DroneInfoTimerInterval); DroneInfoTimer.Tick += new EventHandler(DroneInfoTimer_Elapsed); }