Example #1
0
        void SetConfig()
        {
            var sendConfigTask = new Task(() =>
            {
                Debug("Updating drone settings ...");

                if (_configuration == null)
                {
                    _configuration = new Settings();
                }
                Settings configuration = _configuration;

                if (string.IsNullOrEmpty(configuration.Custom.SessionId) ||
                    configuration.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    _droneClient.AckControlAndWaitForConfirmation(); // wait for the control confirmation

                    configuration.Custom.SessionId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();

                    configuration.Custom.ProfileId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();

                    configuration.Custom.ApplicationId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();
                }

                configuration.Control.Outdoor            = this.Details.OutdoorFlight;
                configuration.Control.FlightWithoutShell = this.Details.OutdoorHull;

                configuration.Control.AltitudeMax = (int)this.Details.AltitudeLimit;

                //if (this.Details.OutdoorFlight == false)
                {
                    //configuration.Control.ControlVzMax = 1f; // (float)this.Details.VerticalSpeedMax;
                    configuration.Control.ControlYaw = 0.10f; // (float)this.Details.RotationSpeedMax;
                    //configuration.Control.EulerAngleMax = 0.1f; // (float)this.Details.TiltAngleMax;
                }
                //else
                //{
                //    _configuration.Control.OutdoorControlVzMax = (float)this.Details.VerticalSpeedMax;
                //    _configuration.Control.OutdoorControlYaw = (float)this.Details.RotationSpeedMax;
                //    _configuration.Control.OutdoorEulerAngleMax = (float)this.Details.TiltAngleMax;
                //}

                this._droneClient.Send(configuration);

                Debug("New drone settings sent!");
            });

            sendConfigTask.Start();
        }
        private void btnSendConfig_Click(object sender, EventArgs e)
        {
            var sendConfigTask = new Task(() =>
            {
                if (_settings == null)
                {
                    _settings = new Settings();
                }
                Settings settings = _settings;

                if (string.IsNullOrEmpty(settings.Custom.SessionId) ||
                    settings.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    _droneClient.AckControlAndWaitForConfirmation();     // wait for the control confirmation

                    settings.Custom.SessionId = Settings.NewId();
                    _droneClient.Send(settings);

                    _droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ProfileId = Settings.NewId();
                    _droneClient.Send(settings);

                    _droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ApplicationId = Settings.NewId();
                    _droneClient.Send(settings);

                    _droneClient.AckControlAndWaitForConfirmation();
                }

                settings.General.NavdataDemo    = false;
                settings.General.NavdataOptions = NavdataOptions.All;
                //settings.General.NavdataOptions = NavdataOptions.GPS;

                settings.Video.BitrateCtrlMode = VideoBitrateControlMode.Dynamic;
                settings.Video.Bitrate         = 1000;
                settings.Video.MaxBitrate      = 2000;

                //settings.Leds.LedAnimation = new LedAnimation(LedAnimationType.BlinkGreenRed, 2.0f, 2);
                //settings.Control.FlightAnimation = new FlightAnimation(FlightAnimationType.Wave);

                // record video to usb
                //settings.Video.OnUsb = true;
                // usage of MP4_360P_H264_720P codec is a requirement for video recording to usb
                //settings.Video.Codec = VideoCodecType.MP4_360P_H264_720P;
                // start
                //settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Start);
                // stop
                //settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Stop);


                //send all changes in one pice
                _droneClient.Send(settings);
            });

            sendConfigTask.Start();
        }
        private void btnSendConfig_Click(object sender, EventArgs e)
        {
            var sendConfigTask = new Task(() =>
            {
                if (_configuration == null)
                {
                    _configuration = new Settings();
                }
                Settings configuration = _configuration;

                if (string.IsNullOrEmpty(configuration.Custom.SessionId) ||
                    configuration.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    _droneClient.AckControlAndWaitForConfirmation();     // wait for the control confirmation

                    configuration.Custom.SessionId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();

                    configuration.Custom.ProfileId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();

                    configuration.Custom.ApplicationId = Settings.NewId();
                    _droneClient.Send(configuration);

                    _droneClient.AckControlAndWaitForConfirmation();
                }

                //configuration.Control.AltitudeMax = 6000;


                configuration.General.NavdataDemo    = false;
                configuration.General.NavdataOptions = NavdataOptions.All;

                configuration.Video.BitrateCtrlMode = VideoBitrateControlMode.Dynamic;
                configuration.Video.Bitrate         = 1000;
                configuration.Video.MaxBitrate      = 2000;

                // record video to usb
                //configuration.Video.OnUsb = true;
                // usage of MP4_360P_H264_720P codec is a requariment for video recording to usb
                //configuration.Video.Codec = VideoCodecType.MP4_360P_H264_720P;
                // start
                //configuration.Userbox.Command = new UserboxCommand(UserboxCommandType.Start);
                // stop
                //configuration.Userbox.Command = new UserboxCommand(UserboxCommandType.Stop);


                //send all changes in one pice
                _droneClient.Send(configuration);
            });

            sendConfigTask.Start();
        }
Example #4
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        Debug.Log("Start DroneObserver");
        // initialize data array
        data          = new byte[width * height * 3];
        cameraTexture = new Texture2D(width, height);
        // Initialize drone
        videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.RGB24, true, OnVideoPacketDecoded);
        videoPacketDecoderWorker.Start();

        droneClient = new DroneClient("192.168.1.1");
        //droneClient = new DroneClient ("127.0.0.1");
        droneClient.UnhandledException     += HandleUnhandledException;
        droneClient.VideoPacketAcquired    += OnVideoPacketAcquired;
        droneClient.NavigationDataAcquired += navData => navigationData = navData;

        droneClient.FlatTrim();

        videoPacketDecoderWorker.UnhandledException += HandleUnhandledException;
        droneClient.Start();

        Settings settings = new Settings();

        settings.Video.Codec = VideoCodecType.H264_720P;
        droneClient.Send(settings);
        droneClient.AckControlAndWaitForConfirmation();

        switchDroneCamera(AR.Drone.Client.Configuration.VideoChannelType.Horizontal);

        isDroneConnected = droneClient.IsConnected;

        if (!isDroneConnected)
        {
            Debug.LogError("Drone not Connected. Retry!!!");
        }
        if (isDroneConnected)
        {
            Debug.LogWarning("Drone Connected!!!");
        }

        // determine connection
        wlanClient = new WlanClient();
    }
Example #5
0
        public Settings GetConfiguration(CancellationToken token)
        {
            using (var tcpClient = new TcpClient(_client.NetworkConfiguration.DroneHostname, ControlPort))
                using (NetworkStream stream = tcpClient.GetStream())
                {
                    _client.AckControlAndWaitForConfirmation();

                    _client.Send(ControlCommand.CfgGetControlMode);

                    var       buffer          = new byte[NetworkBufferSize];
                    Stopwatch swConfigTimeout = Stopwatch.StartNew();
                    while (swConfigTimeout.ElapsedMilliseconds < ConfigTimeout)
                    {
                        token.ThrowIfCancellationRequested();

                        int offset = 0;
                        if (tcpClient.Available == 0)
                        {
                            Thread.Sleep(20);
                        }
                        else
                        {
                            offset += stream.Read(buffer, offset, buffer.Length);
                            swConfigTimeout.Reset();
                            swConfigTimeout.Start();

                            // config eof check
                            if (offset > 0 && buffer[offset - 1] == 0x00)
                            {
                                string s = System.Text.Encoding.UTF8.GetString(buffer, 0, offset);

                                return(Settings.Parse(s));
                            }
                        }
                    }

                    throw new TimeoutException();
                }
        }
Example #6
0
        public void Configure(DroneConfiguration droneConfiguration)
        {
            Task <Settings> configurationTask = droneClient.GetConfigurationTask();

            configurationTask.ContinueWith(
                delegate(Task <Settings> task)
            {
                if (task.Exception != null)
                {
                    Trace.TraceWarning("Get configuration task is faulted with exception: {0}",
                                       task.Exception.InnerException.Message);
                    return;
                }

                settings = task.Result;
            });
            configurationTask.Start();

            var sendConfigTask = new Task(() =>
            {
                if (settings == null)
                {
                    settings = new Settings();
                }

                if (string.IsNullOrEmpty(settings.Custom.SessionId) ||
                    settings.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    droneClient.AckControlAndWaitForConfirmation(); // wait for the control confirmation

                    settings.Custom.SessionId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ProfileId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ApplicationId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();
                }

                settings.General.NavdataDemo    = false;
                settings.General.NavdataOptions = NavdataOptions.All;

                //settings.Video.BitrateCtrlMode = VideoBitrateControlMode.Dynamic;
                settings.Video.Bitrate    = 1000;
                settings.Video.MaxBitrate = 2000;

                settings.Leds.LedAnimation       = new LedAnimation(LedAnimationType.BlinkGreenRed, 2.0f, 2);
                settings.Control.FlightAnimation = new FlightAnimation(FlightAnimationType.Wave);


                //start
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Start);
                //stop
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Stop);

                //send all changes in one pice
                droneClient.Send(settings);

                droneClient.FlatTrim(); // calibrates the drone on flat surface
            });

            sendConfigTask.Start();
        }