/// <summary> /// Switchs the drone camera. /// </summary> /// <param name="Type">Video channel type.</param> private void switchDroneCamera(AR.Drone.Client.Configuration.VideoChannelType Type) { var configuration = new AR.Drone.Client.Configuration.Settings(); configuration.Video.Channel = Type; droneClient.Send(configuration); }
public static Settings Parse(string input) { var configuration = new Settings(); MatchCollection matches = ReKeyValue.Matches(input); foreach (Match match in matches) { string key = match.Groups["key"].Value; string value = match.Groups["value"].Value; configuration._items.Add(key, value); } return configuration; }
/// <summary> /// Requests the current configuration from the drone asynchronously. /// Triggers OnSettingsReceived when completed /// Settings/Results are loaded to the settings variale /// </summary> private void ReadDroneConfig() { // If the drone is not connected, droneClient will throw an exception // although there is some exeption handling if (droneClient.IsConnected) { 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; this.Invoke(new SettingsReceived(OnSettingsReceived)); }); configurationTask.Start(); } }
public GeneralSection(Settings settings) : base(settings, "general") { }
public CustomSection(Settings settings) : base(settings, "custom") { }
public GpsSection(Settings settings) : base(settings, "gps") { }
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.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 btnSwitchCam_Click(object sender, EventArgs e) { var configuration = new Settings(); configuration.Video.Channel = VideoChannelType.Next; _droneClient.Send(configuration); }
public LedsSection(Settings settings) : base(settings, "leds") { }
public VideoSection(Settings settings) : base(settings, "video") { }
public PicSection(Settings settings) : base(settings, "pic") { }
public NetworkSection(Settings settings) : base(settings, "network") { }
public ControlSection(Settings settings) : base(settings, "control") { }
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.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 settings.Control.AltitudeMax = 10000; //it's over NEIN THOUSAND!!! settings.Control.AltitudeMin = 0; settings.Control.ControlVzMax = (float)maxVz.Value; settings.Control.ControlYaw = (float)maxYaw.Value; settings.Control.EulerAngleMax = 1.0f; if(radioSelect22Hz.Checked)settings.Pic.UltrasoundFreq = 7; //set the ultrasound at 22,22Hz else if (radioSelect25Hz.Checked) settings.Pic.UltrasoundFreq = 8; //set the ultrasound at 25Hz _droneClient.Send(settings); }); sendConfigTask.Start(); }
public void Send(Settings settings) { KeyValuePair<string, string> item; while (settings.Changes.TryDequeue(out item)) { if (string.IsNullOrEmpty(settings.Custom.SessionId) == false && string.IsNullOrEmpty(settings.Custom.ProfileId) == false && string.IsNullOrEmpty(settings.Custom.ApplicationId) == false) Send(new ConfigIdsCommand(settings.Custom.SessionId, settings.Custom.ProfileId, settings.Custom.ApplicationId)); Send(new ConfigCommand(item.Key, item.Value)); } }
private void ProcessStateTransitions(NavigationState state) { if (state.HasFlag(NavigationState.Bootstrap)) { _commandQueue.Flush(); var settings = new Settings(); settings.General.NavdataDemo = false; Send(settings); } if (state.HasFlag(NavigationState.Watchdog)) { Trace.TraceWarning("Communication Watchdog!"); } switch (_stateRequest) { case StateRequest.None: return; case StateRequest.Emergency: if (state.HasFlag(NavigationState.Flying)) Send(RefCommand.Emergency); else _stateRequest = StateRequest.None; break; case StateRequest.ResetEmergency: Send(RefCommand.Emergency); _stateRequest = StateRequest.None; break; case StateRequest.Land: if (state.HasFlag(NavigationState.Flying) && state.HasFlag(NavigationState.Landing) == false) { Send(RefCommand.Land); } else _stateRequest = StateRequest.None; break; case StateRequest.Fly: if (state.HasFlag(NavigationState.Landed) && state.HasFlag(NavigationState.Takeoff) == false && state.HasFlag(NavigationState.Emergency) == false) { Send(RefCommand.Takeoff); } else _stateRequest = StateRequest.None; break; default: throw new ArgumentOutOfRangeException(); } }
public DetectSection(Settings settings) : base(settings, "detect") { }
private void btnReadConfig_Click(object sender, EventArgs e) { 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(); }
public SyslogSection(Settings settings) : base(settings, "syslog") { }
public UserboxSection(Settings settings) : base(settings, "userbox") { }
// 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; } }