private void InitializeVideoFeedModule() { this.videoParser = new DJIVideoParser.Parser(); this.videoParser.Initialize(); this.videoParser.SetVideoDataCallack(0, 0, ReceiveDecodedData); if (DJISDKManager.Instance.SDKRegistrationResultCode == SDKError.NO_ERROR) { DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; } }
public MainPage() { this.InitializeComponent(); //Listen for registration success DJISDKManager.Instance.SDKRegistrationStateChanged += async(state, result) => { if (state != SDKRegistrationState.Succeeded) { var md = new MessageDialog(result.ToString()); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await md.ShowAsync()); return; } //wait till initialization finish //use a large enough time and hope for the best await Task.Delay(1000); videoParser = new DJIVideoParser.Parser(); videoParser.Initialize(); videoParser.SetVideoDataCallack(0, 0, ReceiveDecodedData); DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetObstacleAvoidanceEnabledAsync(new BoolMsg() { value = false }); await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetVisionAssistedPositioningEnabledAsync(new BoolMsg() { value = true }); await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetLandingProtectionEnabledAsync(new BoolMsg() { value = false }); await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).StartAlignedPushDataAsync(); await Task.Delay(5000); }; DJISDKManager.Instance.RegisterApp("3ad4ddfffc9f656725e12c34"); //subscribing event handlers //DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).TakeoffLocationAltitudeChanged += getTakeoffLocationAltitudeChanged; DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AttitudeChanged += GetAttitudeChanged; DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AltitudeChanged += GetAltitudeChanged; DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).AlignedAircraftLocationChanged += GetAlignedAircraftLocationChanged; //DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AircraftLocationChanged += getAircraftLocationChanged; }
private void InitializeVideoFeedModule() { try { this.videoParser = new DJIVideoParser.Parser(); } catch (FileNotFoundException e) { Debug.WriteLine(e.FileName); } this.videoParser.Initialize(); this.videoParser.SetVideoDataCallack(0, 0, ReceiveDecodedData); Debug.WriteLine(DJISDKManager.Instance.SDKRegistrationResultCode); if (DJISDKManager.Instance.SDKRegistrationResultCode == SDKError.NO_ERROR) { //Register event receiver DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; } }
public MainWindow() { this.InitializeComponent(); //Listen for registration success Focus(FocusState.Keyboard); DJISDKManager.Instance.SDKRegistrationStateChanged += async(state, result) => { if (state != SDKRegistrationState.Succeeded) { var md = new MessageDialog(result.ToString()); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await md.ShowAsync()); return; } //wait till initialization finish //use a large enough time and hope for the best await Task.Delay(1000); videoParser = new DJIVideoParser.Parser(); videoParser.Initialize(); videoParser.SetVideoDataCallack(0, 0, ReceiveDecodedData); DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetObstacleAvoidanceEnabledAsync(new BoolMsg() { value = false }); await Task.Delay(5000); GimbalResetCommandMsg resetMsg = new GimbalResetCommandMsg() { value = GimbalResetCommand.UNKNOWN }; await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).ResetGimbalAsync(resetMsg); }; DJISDKManager.Instance.RegisterApp("489330473bb6ed62837e4f05"); }
public MainPage() { this.InitializeComponent(); //Listen for registration success Focus(FocusState.Keyboard); DJISDKManager.Instance.SDKRegistrationStateChanged += async(state, result) => { if (state != SDKRegistrationState.Succeeded) { var md = new MessageDialog(result.ToString()); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await md.ShowAsync()); return; } //wait till initialization finish //use a large enough time and hope for the best await Task.Delay(1000); videoParser = new DJIVideoParser.Parser(); videoParser.Initialize(); videoParser.SetVideoDataCallack(0, 0, ReceiveDecodedData); DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetObstacleAvoidanceEnabledAsync(new BoolMsg() { value = false }); await Task.Delay(5000); GimbalResetCommandMsg resetMsg = new GimbalResetCommandMsg() { value = GimbalResetCommand.UNKNOWN }; await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).ResetGimbalAsync(resetMsg); }; DJISDKManager.Instance.RegisterApp("489330473bb6ed62837e4f05"); //Call once to initialize fields SetControlState(false); this._timer = new Stopwatch(); this._timer.Start(); var flightAssistant = DJISDKManager.Instance?.ComponentManager.GetFlightAssistantHandler(0, 0); flightAssistant?.SetVisionAssistedPositioningEnabledAsync(new BoolMsg { value = true }); flightAssistant?.SetObstacleAvoidanceEnabledAsync(new BoolMsg { value = true }); var flightController = DJISDKManager.Instance?.ComponentManager.GetFlightControllerHandler(0, 0); var attitudeUpdateTimer = new Stopwatch(); attitudeUpdateTimer.Start(); flightController.AttitudeChanged += (sender, value) => { _attitudeInterval = attitudeUpdateTimer.Elapsed; attitudeUpdateTimer.Restart(); if (value.HasValue) { _attitude = new Attitude { pitch = value.Value.pitch, roll = value.Value.roll, yaw = value.Value.yaw }; } UpdateYawCommand(); UpdateAction(); UpdateDebugPrintBoxAsync(); }; var heightUpdateTimer = new Stopwatch(); heightUpdateTimer.Start(); flightController.AltitudeChanged += (sender, value) => { _heightInterval = heightUpdateTimer.Elapsed; heightUpdateTimer.Restart(); if (value.HasValue) { _height = value.Value.value; } UpdateHeightCommand(); UpdateAction(); UpdateDebugPrintBoxAsync(); }; }