Example #1
0
        public MainForm()
        {
            InitializeComponent();

            Text += Environment.Is64BitProcess ? " [64-bit]" : " [32-bit]";

            _videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded);
            _videoPacketDecoderWorker.Start();

            string path = string.Format("flight_{0:yyyy-MM-dd-HH-mm}.ardrone", DateTime.Now);
            var stream = new FileStream(path, FileMode.OpenOrCreate);
            _packetRecorderWorker = new PacketRecorder(stream);
            _packetRecorderWorker.Start();

            _droneClient = new DroneClient();
            _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired;
            _droneClient.VideoPacketAcquired += OnVideoPacketAcquired;
            _droneClient.ConfigurationUpdated += OnConfigurationUpdated;
            _droneClient.Active = true;

            tmrStateUpdate.Enabled = true;
            tmrVideoUpdate.Enabled = true;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // Speech synth Initialization
            //TODO: Check synth initialize result
            InitializeSynth();

            // AR Drone Initialization
            _videoPacketDecoderWorker = new VideoPacketDecoderWorker(AR.Drone.Video.PixelFormat.BGR24, true, OnVideoPacketDecoded);
            _videoPacketDecoderWorker.Start();

            string path = string.Format("flight_{0:yyyy-MM-dd-HH-mm}.ardrone", DateTime.Now);
            var stream = new FileStream(path, FileMode.OpenOrCreate);
            _packetRecorderWorker = new PacketRecorder(stream);
            _packetRecorderWorker.Start();

            _droneClient = new DroneClient();
            _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired;
            _droneClient.VideoPacketAcquired += OnVideoPacketAcquired;
            _droneClient.ConfigurationUpdated += OnConfigurationUpdated;
            _droneClient.Active = true;

            //tmrStateUpdate.Enabled = true;
            //tmrVideoUpdate.Enabled = true;

        }
Example #3
0
        private void btnStartRecording_Click(object sender, EventArgs e)
        {
            string path = string.Format("flight_{0:yyyy_MM_dd_HH_mm}" + ARDroneTrackFileExt, DateTime.Now);

            using (var dialog = new SaveFileDialog {DefaultExt = ARDroneTrackFileExt, Filter = ARDroneTrackFilesFilter, FileName = path})
            {
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    StopRecording();

                    _recorderStream = new FileStream(dialog.FileName, FileMode.OpenOrCreate);
                    _packetRecorderWorker = new PacketRecorder(_recorderStream);
                    _packetRecorderWorker.Start();
                }
            }
        }
Example #4
0
        // Activate/deactive autopilot
        private void Main_Form_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.F:
                    _droneClient.FlatTrim();
                    break;
                case Keys.Back:
                    if (!isSensitiveMode)
                    {
                        flightSensitivityConst = 0.25f;
                        isSensitiveMode = true;
                    }
                    else
                    {
                        flightSensitivityConst = 0.9f;
                        isSensitiveMode = false;
                    }

                    break;
                case Keys.W:
                    _droneClient.Progress(FlightMode.Progressive, pitch: -flightSensitivityConst);
                    break;
                case Keys.S:
                    _droneClient.Progress(FlightMode.Progressive, pitch: flightSensitivityConst);
                    break;
                case Keys.A:
                    _droneClient.Progress(FlightMode.Progressive, roll: -flightSensitivityConst);
                    break;
                case Keys.D:
                    _droneClient.Progress(FlightMode.Progressive, roll: +flightSensitivityConst);
                    break;
                case Keys.Up:
                    _droneClient.Progress(FlightMode.Progressive, gaz: flightSensitivityConst);
                    break;
                case Keys.Down:
                    _droneClient.Progress(FlightMode.Progressive, gaz: -flightSensitivityConst);
                    break;
                case Keys.Left:
                    _droneClient.Progress(FlightMode.Progressive, yaw: -flightSensitivityConst);
                    break;
                case Keys.Right:
                    _droneClient.Progress(FlightMode.Progressive, yaw: +flightSensitivityConst);
                    break;
                case Keys.E:
                    _droneClient.Takeoff();
                    break;
                case Keys.Space:
                    _droneClient.Land();
                    break;
                case Keys.C:
                    var configuration = new Settings();
                    configuration.Video.Channel = VideoChannelType.Next;
                    _droneClient.Send(configuration);
                    break;
                case Keys.R:
                    string path = string.Format("ttu_flight_{0:yyyy_MM_dd_HH_mm}" + ARDroneTrackFileExt, DateTime.Now);
                    using (var dialog = new SaveFileDialog { DefaultExt = ARDroneTrackFileExt, Filter = ARDroneTrackFilesFilter, FileName = path })
                    {
                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            StopRecording();

                            _recorderStream = new FileStream(dialog.FileName, FileMode.OpenOrCreate);
                            _packetRecorderWorker = new PacketRecorder(_recorderStream);
                            _packetRecorderWorker.Start();
                        }
                    }
                    break;
            }
        }