public GeneralSection(DroneConfiguration configuration) : base(configuration, "general") { ConfigVersion = new ReadOnlyItem <int>(this, "num_version_config"); MotherboardVersion = new ReadOnlyItem <int>(this, "num_version_mb"); SoftVersion = new ReadOnlyItem <string>(this, "num_version_soft"); DroneSerial = new ReadOnlyItem <string>(this, "drone_serial"); SoftBuildDate = new ReadOnlyItem <string>(this, "soft_build_date"); Motor1Soft = new ReadOnlyItem <string>(this, "motor1_soft"); Motor1Hard = new ReadOnlyItem <string>(this, "motor1_hard"); Motor1Supplier = new ReadOnlyItem <string>(this, "motor1_supplier"); Motor2Soft = new ReadOnlyItem <string>(this, "motor2_soft"); Motor2Hard = new ReadOnlyItem <string>(this, "motor2_hard"); Motor2Supplier = new ReadOnlyItem <string>(this, "motor2_supplier"); Motor3Soft = new ReadOnlyItem <string>(this, "motor3_soft"); Motor3Hard = new ReadOnlyItem <string>(this, "motor3_hard"); Motor3Supplier = new ReadOnlyItem <string>(this, "motor3_supplier"); Motor4Soft = new ReadOnlyItem <string>(this, "motor4_soft"); Motor4Hard = new ReadOnlyItem <string>(this, "motor4_hard"); Motor4Supplier = new ReadOnlyItem <string>(this, "motor4_supplier"); ARDroneName = new ActiveItem <string>(this, "ardrone_name"); FlyingTime = new ReadOnlyItem <int>(this, "flying_time"); NavdataDemo = new ActiveItem <bool>(this, "navdata_demo"); NavdataOptions = new ActiveItem <int>(this, "navdata_options"); ComWatchdog = new ActiveItem <int>(this, "com_watchdog"); Video = new ActiveItem <bool>(this, "video_enable"); Vision = new ActiveItem <bool>(this, "vision_enable"); BatteryVoltageMin = new ActiveItem <int>(this, "vbat_min"); LocalTime = new ActiveItem <int>(this, "localtime"); }
public static bool TryUpdate(DroneConfiguration configuration, ConfigurationPacket packet) { bool updated = false; using (var ms = new MemoryStream(packet.Data)) using (var sr = new StreamReader(ms)) { string line; while ((line = sr.ReadLine()) != null) { Match match = _reKeyValue.Match(line); if (match.Success) { string key = match.Groups["key"].Value; IConfigurationItem item; if (configuration.Items.TryGetValue(key, out item)) { string value = match.Groups["value"].Value; if (item.TryUpdate(value)) { updated = true; } else { Trace.TraceWarning("Configuration key {0} update failed. Original line: {1}", key, line); } } else { Trace.TraceWarning("Configuration key {0} is not supported by parser. Original line: {1}", key, line); } } } } return updated; }
public PicSection(DroneConfiguration configuration) : base(configuration, "pic") { UltrasoundFreq = new ActiveItem <int>(this, "ultrasound_freq"); UltrasoundWatchdog = new ActiveItem <int>(this, "ultrasound_watchdog"); Version = new ReadOnlyItem <int>(this, "pic_version"); }
public static bool TryUpdate(DroneConfiguration configuration, ConfigurationPacket packet) { bool updated = false; using (var ms = new MemoryStream(packet.Data)) using (var sr = new StreamReader(ms)) { string line; while ((line = sr.ReadLine()) != null) { Match match = _reKeyValue.Match(line); if (match.Success) { string key = match.Groups["key"].Value; IConfigurationItem item; if (configuration.Items.TryGetValue(key, out item)) { string value = match.Groups["value"].Value; if (item.TryUpdate(value)) { updated = true; } } else { Trace.TraceWarning("Configuration key {0} is not supported by parser. Original line: {1}", key, line); } } } } return(updated); }
public SyslogSection(DroneConfiguration configuration) : base(configuration, "syslog") { Output = new ActiveItem <int>(this, "output"); MaxSize = new ActiveItem <int>(this, "max_size"); NbFiles = new ActiveItem <int>(this, "nb_files"); }
public GpsSection(DroneConfiguration configuration) : base(configuration, "gps") { Latitude = new ReadOnlyItem <double>(this, "latitude"); Longitude = new ReadOnlyItem <double>(this, "longitude"); Altitude = new ReadOnlyItem <double>(this, "altitude"); }
private void OnConfigurationUpdated(DroneConfiguration configuration) { if (configuration.Video.Codec != VideoCodecType.H264_360P || configuration.Video.BitrateCtrlMode != VideoBitrateControlMode.Dynamic) { _droneClient.Send(configuration.Video.Codec.Set(VideoCodecType.H264_360P).ToCommand()); _droneClient.Send(configuration.Video.BitrateCtrlMode.Set(VideoBitrateControlMode.Dynamic).ToCommand()); } }
public NetworkSection(DroneConfiguration configuration) : base(configuration, "network") { SsidSinglePlayer = new ActiveItem <string>(this, "ssid_single_player"); SsidMultiPlayer = new ActiveItem <string>(this, "ssid_multi_player"); WifiMode = new ActiveItem <int>(this, "wifi_mode"); WifiRate = new ActiveItem <int>(this, "wifi_rate"); OwnerMac = new ActiveItem <string>(this, "owner_mac"); }
public CustomSection(DroneConfiguration configuration) : base(configuration, "custom") { ApplicationId = new ReadOnlyItem <string>(this, "application_id"); ApplicationDescription = new ReadOnlyItem <string>(this, "application_desc"); ProfileId = new ReadOnlyItem <string>(this, "profile_id"); ProfileDescription = new ReadOnlyItem <string>(this, "profile_desc"); SessionId = new ReadOnlyItem <string>(this, "session_id"); SessionDescription = new ReadOnlyItem <string>(this, "session_desc"); }
public DetectSection(DroneConfiguration configuration) : base(configuration, "detect") { EnemyColors = new ActiveItem <int>(this, "enemy_colors"); GroundstripeColors = new ActiveItem <int>(this, "groundstripe_colors"); EnemyWithoutShell = new ActiveItem <int>(this, "enemy_without_shell"); DetectType = new ActiveItem <int>(this, "detect_type"); DetectionsSelectH = new ActiveItem <int>(this, "detections_select_h"); DetectionsSelectVHsync = new ActiveItem <int>(this, "detections_select_v_hsync"); DetectionsSelectV = new ActiveItem <int>(this, "detections_select_v"); }
public DroneClient() { _configuration = new DroneConfiguration(); _commandQueue = new ConcurrentQueue<ATCommand>(); _commandSender = new CommandSender(_configuration, _commandQueue); _navdataAcquisition = new NavdataAcquisition(_configuration, OnNavdataPacketAcquired, OnNavdataAcquisitionStopped); _videoAcquisition = new VideoAcquisition(_configuration, OnVideoPacketAcquired); _configurationAcquisition = new ConfigurationAcquisition(_configuration, OnConfigurationPacketAcquired); _watchdog = new Watchdog(_navdataAcquisition, _commandSender, _videoAcquisition); }
public DroneClient() { _configuration = new DroneConfiguration(); _commandQueue = new ConcurrentQueue<ATCommand>(); _networkWorker = new NetworkWorker(_configuration, OnConnectionChanged); _commandQueueWorker = new CommandQueueWorker(_configuration, _commandQueue); _navdataAcquisitionWorker = new NavdataAcquisitionWorker(_configuration, OnNavigationPacketAcquired); _videoAcquisitionWorker = new VideoAcquisitionWorker(_configuration, OnVideoPacketAcquired); _configurationAcquisitionWorker = new ConfigurationAcquisitionWorker(_configuration, OnConfigurationPacketAcquired); _watchdogWorker = new WatchdogWorker(_networkWorker, _navdataAcquisitionWorker, _commandQueueWorker, _videoAcquisitionWorker); }
public DroneConfiguration GetConfiguration(CancellationToken token) { using (var tcpClient = new TcpClient(_client.NetworkConfiguration.DroneHostname, ControlPort)) using (NetworkStream stream = tcpClient.GetStream()) try { _client.NavigationDataAcquired += OnNavigationData; var buffer = new byte[NetworkBufferSize]; Stopwatch swConfigTimeout = Stopwatch.StartNew(); while (swConfigTimeout.ElapsedMilliseconds < ConfigTimeout) { token.ThrowIfCancellationRequested(); int offset = 0; if (tcpClient.Available == 0) { Thread.Sleep(10); } else { offset += stream.Read(buffer, offset, buffer.Length); swConfigTimeout.Restart(); // config eof check if (offset > 0 && buffer[offset - 1] == 0x00) { var data = new byte[offset]; Array.Copy(buffer, data, offset); var packet = new ConfigurationPacket { Timestamp = DateTime.UtcNow.Ticks, Data = data }; var configuration = new DroneConfiguration(); if (ConfigurationPacketParser.TryUpdate(configuration, packet)) { return(configuration); } throw new InvalidDataException(); } } } throw new TimeoutException(); } finally { _client.NavigationDataAcquired -= OnNavigationData; } }
public DroneConfiguration GetConfiguration(CancellationToken token) { using (var tcpClient = new TcpClient(_client.NetworkConfiguration.DroneHostname, ControlPort)) using (NetworkStream stream = tcpClient.GetStream()) try { _client.NavigationDataAcquired += OnNavigationData; var buffer = new byte[NetworkBufferSize]; Stopwatch swConfigTimeout = Stopwatch.StartNew(); while (swConfigTimeout.ElapsedMilliseconds < ConfigTimeout) { token.ThrowIfCancellationRequested(); int offset = 0; if (tcpClient.Available == 0) { Thread.Sleep(10); } else { offset += stream.Read(buffer, offset, buffer.Length); swConfigTimeout.Restart(); // config eof check if (offset > 0 && buffer[offset - 1] == 0x00) { var data = new byte[offset]; Array.Copy(buffer, data, offset); var packet = new ConfigurationPacket { Timestamp = DateTime.UtcNow.Ticks, Data = data }; var configuration = new DroneConfiguration(); if (ConfigurationPacketParser.TryUpdate(configuration, packet)) { return configuration; } throw new InvalidDataException(); } } } throw new TimeoutException(); } finally { _client.NavigationDataAcquired -= OnNavigationData; } }
public VideoSection(DroneConfiguration configuration) : base(configuration, "video") { CamifFps = new ReadOnlyItem <int>(this, "camif_fps"); CodecFps = new ActiveItem <int>(this, "codec_fps"); CamifBuffers = new ReadOnlyItem <int>(this, "camif_buffers"); Trackers = new ReadOnlyItem <int>(this, "num_trackers"); Codec = new ActiveItem <VideoCodecType>(this, "video_codec"); Slices = new ActiveItem <int>(this, "video_slices"); LiveSocket = new ActiveItem <int>(this, "video_live_socket"); StorageSpace = new ReadOnlyItem <int>(this, "video_storage_space"); Bitrate = new ActiveItem <int>(this, "bitrate"); MaxBitrate = new ActiveItem <int>(this, "max_bitrate"); BitrateCtrlMode = new ActiveItem <VideoBitrateControlMode>(this, "bitrate_ctrl_mode"); BitrateStorage = new ActiveItem <int>(this, "bitrate_storage"); Channel = new ActiveItem <VideoChannelType>(this, "video_channel"); OnUsb = new ActiveItem <bool>(this, "video_on_usb"); FileIndex = new ActiveItem <int>(this, "video_file_index"); }
public ControlSection(DroneConfiguration configuration) : base(configuration, "control") { accs_offset = new ReadOnlyItem <string>(this, "accs_offset"); accs_gains = new ReadOnlyItem <string>(this, "accs_gains"); gyros_offset = new ReadOnlyItem <string>(this, "gyros_offset"); gyros_gains = new ReadOnlyItem <string>(this, "gyros_gains"); gyros110_offset = new ReadOnlyItem <string>(this, "gyros110_offset"); gyros110_gains = new ReadOnlyItem <string>(this, "gyros110_gains"); magneto_offset = new ReadOnlyItem <string>(this, "magneto_offset"); magneto_radius = new ReadOnlyItem <float>(this, "magneto_radius"); gyro_offset_thr_x = new ReadOnlyItem <float>(this, "gyro_offset_thr_x"); gyro_offset_thr_y = new ReadOnlyItem <float>(this, "gyro_offset_thr_y"); gyro_offset_thr_z = new ReadOnlyItem <float>(this, "gyro_offset_thr_z"); pwm_ref_gyros = new ReadOnlyItem <int>(this, "pwm_ref_gyros"); osctun_value = new ReadOnlyItem <int>(this, "osctun_value"); osctun_test = new ReadOnlyItem <bool>(this, "osctun_test"); control_level = new ActiveItem <int>(this, "control_level"); euler_angle_max = new ActiveItem <float>(this, "euler_angle_max"); altitude_max = new ActiveItem <int>(this, "altitude_max"); altitude_min = new ActiveItem <int>(this, "altitude_min"); control_iphone_tilt = new ActiveItem <float>(this, "control_iphone_tilt"); control_vz_max = new ActiveItem <float>(this, "control_vz_max"); control_yaw = new ActiveItem <float>(this, "control_yaw"); outdoor = new ActiveItem <bool>(this, "outdoor"); flight_without_shell = new ActiveItem <bool>(this, "flight_without_shell"); autonomous_flight = new ReadOnlyItem <bool>(this, "autonomous_flight"); // obsolete manual_trim = new ActiveItem <bool>(this, "manual_trim"); indoor_euler_angle_max = new ActiveItem <float>(this, "indoor_euler_angle_max"); indoor_control_vz_max = new ActiveItem <float>(this, "indoor_control_vz_max"); indoor_control_yaw = new ActiveItem <float>(this, "indoor_control_yaw"); outdoor_euler_angle_max = new ActiveItem <float>(this, "outdoor_euler_angle_max"); outdoor_control_vz_max = new ActiveItem <float>(this, "outdoor_control_vz_max"); outdoor_control_yaw = new ActiveItem <float>(this, "outdoor_control_yaw"); flying_mode = new ActiveItem <int>(this, "flying_mode"); hovering_range = new ActiveItem <int>(this, "hovering_range"); flight_anim = new FlightAnimationItem(this, "flight_anim"); }
public PicSection(DroneConfiguration configuration) : base(configuration, "pic") { UltrasoundFreq = new ActiveItem<int>(this, "ultrasound_freq"); UltrasoundWatchdog = new ActiveItem<int>(this, "ultrasound_watchdog"); Version = new ReadOnlyItem<int>(this, "pic_version"); }
public UserboxSection(DroneConfiguration configuration) : base(configuration, "userbox") { UserboxCmd = new ActiveItem <string>(this, "userbox_cmd"); }
public GpsSection(DroneConfiguration configuration) : base(configuration, "gps") { Latitude = new ReadOnlyItem<double>(this, "latitude"); Longitude = new ReadOnlyItem<double>(this, "longitude"); Altitude = new ReadOnlyItem<double>(this, "altitude"); }
public UserboxSection(DroneConfiguration configuration) : base(configuration, "userbox") { UserboxCmd = new ActiveItem<string>(this, "userbox_cmd"); }
public LedsSection(DroneConfiguration configuration) : base(configuration, "leds") { Animation = new ActiveItem <string>(this, "leds_anim"); }
public LedsSection(DroneConfiguration configuration) : base(configuration, "leds") { Animation = new ActiveItem<string>(this, "leds_anim"); }
public VideoSection(DroneConfiguration configuration) : base(configuration, "video") { CamifFps = new ReadOnlyItem<int>(this, "camif_fps"); CodecFps = new ActiveItem<int>(this, "codec_fps"); CamifBuffers = new ReadOnlyItem<int>(this, "camif_buffers"); Trackers = new ReadOnlyItem<int>(this, "num_trackers"); Codec = new ActiveItem<VideoCodecType>(this, "video_codec"); Slices = new ActiveItem<int>(this, "video_slices"); LiveSocket = new ActiveItem<int>(this, "video_live_socket"); StorageSpace = new ReadOnlyItem<int>(this, "video_storage_space"); Bitrate = new ActiveItem<int>(this, "bitrate"); MaxBitrate = new ActiveItem<int>(this, "max_bitrate"); BitrateCtrlMode = new ActiveItem<VideoBitrateControlMode>(this, "bitrate_ctrl_mode"); BitrateStorage = new ActiveItem<int>(this, "bitrate_storage"); Channel = new ActiveItem<VideoChannelType>(this, "video_channel"); OnUsb = new ActiveItem<bool>(this, "video_on_usb"); FileIndex = new ActiveItem<int>(this, "video_file_index"); }
public SyslogSection(DroneConfiguration configuration) : base(configuration, "syslog") { Output = new ActiveItem<int>(this, "output"); MaxSize = new ActiveItem<int>(this, "max_size"); NbFiles = new ActiveItem<int>(this, "nb_files"); }
public GeneralSection(DroneConfiguration configuration) : base(configuration, "general") { ConfigVersion = new ReadOnlyItem<int>(this, "num_version_config"); MotherboardVersion = new ReadOnlyItem<int>(this, "num_version_mb"); SoftVersion = new ReadOnlyItem<string>(this, "num_version_soft"); DroneSerial = new ReadOnlyItem<string>(this, "drone_serial"); SoftBuildDate = new ReadOnlyItem<string>(this, "soft_build_date"); Motor1Soft = new ReadOnlyItem<string>(this, "motor1_soft"); Motor1Hard = new ReadOnlyItem<string>(this, "motor1_hard"); Motor1Supplier = new ReadOnlyItem<string>(this, "motor1_supplier"); Motor2Soft = new ReadOnlyItem<string>(this, "motor2_soft"); Motor2Hard = new ReadOnlyItem<string>(this, "motor2_hard"); Motor2Supplier = new ReadOnlyItem<string>(this, "motor2_supplier"); Motor3Soft = new ReadOnlyItem<string>(this, "motor3_soft"); Motor3Hard = new ReadOnlyItem<string>(this, "motor3_hard"); Motor3Supplier = new ReadOnlyItem<string>(this, "motor3_supplier"); Motor4Soft = new ReadOnlyItem<string>(this, "motor4_soft"); Motor4Hard = new ReadOnlyItem<string>(this, "motor4_hard"); Motor4Supplier = new ReadOnlyItem<string>(this, "motor4_supplier"); ARDroneName = new ActiveItem<string>(this, "ardrone_name"); FlyingTime = new ReadOnlyItem<int>(this, "flying_time"); NavdataDemo = new ActiveItem<bool>(this, "navdata_demo"); NavdataOptions = new ActiveItem<int>(this, "navdata_options"); ComWatchdog = new ActiveItem<int>(this, "com_watchdog"); Video = new ActiveItem<bool>(this, "video_enable"); Vision = new ActiveItem<bool>(this, "vision_enable"); BatteryVoltageMin = new ActiveItem<int>(this, "vbat_min"); LocalTime = new ActiveItem<int>(this, "localtime"); }
public NetworkSection(DroneConfiguration configuration) : base(configuration, "network") { SsidSinglePlayer = new ActiveItem<string>(this, "ssid_single_player"); SsidMultiPlayer = new ActiveItem<string>(this, "ssid_multi_player"); WifiMode = new ActiveItem<int>(this, "wifi_mode"); WifiRate = new ActiveItem<int>(this, "wifi_rate"); OwnerMac = new ActiveItem<string>(this, "owner_mac"); }
public CustomSection(DroneConfiguration configuration) : base(configuration, "custom") { ApplicationId = new ReadOnlyItem<string>(this, "application_id"); ApplicationDescription = new ReadOnlyItem<string>(this, "application_desc"); ProfileId = new ReadOnlyItem<string>(this, "profile_id"); ProfileDescription = new ReadOnlyItem<string>(this, "profile_desc"); SessionId = new ReadOnlyItem<string>(this, "session_id"); SessionDescription = new ReadOnlyItem<string>(this, "session_desc"); }
public DetectSection(DroneConfiguration configuration) : base(configuration, "detect") { EnemyColors = new ActiveItem<int>(this, "enemy_colors"); GroundstripeColors = new ActiveItem<int>(this, "groundstripe_colors"); EnemyWithoutShell = new ActiveItem<int>(this, "enemy_without_shell"); DetectType = new ActiveItem<int>(this, "detect_type"); DetectionsSelectH = new ActiveItem<int>(this, "detections_select_h"); DetectionsSelectVHsync = new ActiveItem<int>(this, "detections_select_v_hsync"); DetectionsSelectV = new ActiveItem<int>(this, "detections_select_v"); }
private void ProcessStateTransitions(NavigationState state) { if (state.HasFlag(NavigationState.Bootstrap)) { _commandQueue.Flush(); var configuration = new DroneConfiguration(); configuration.General.NavdataDemo.ChangeTo(false); configuration.SendTo(this); Send(new ControlCommand(ControlMode.NoControlMode)); } if (state.HasFlag(NavigationState.Watchdog)) { Trace.TraceWarning("Communication Watchdog!"); } switch (_stateRequest) { case StateRequest.None: return; case StateRequest.Emergency: if (state.HasFlag(NavigationState.Flying)) Send(new RefCommand(RefMode.Emergency)); else _stateRequest = StateRequest.None; break; case StateRequest.ResetEmergency: Send(new RefCommand(RefMode.Emergency)); _stateRequest = StateRequest.None; break; case StateRequest.Land: if (state.HasFlag(NavigationState.Flying) && state.HasFlag(NavigationState.Landing) == false) { Send(new RefCommand(RefMode.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(new RefCommand(RefMode.Takeoff)); } else _stateRequest = StateRequest.None; break; default: throw new ArgumentOutOfRangeException(); } }
public ControlSection(DroneConfiguration configuration) : base(configuration, "control") { accs_offset = new ReadOnlyItem<string>(this, "accs_offset"); accs_gains = new ReadOnlyItem<string>(this, "accs_gains"); gyros_offset = new ReadOnlyItem<string>(this, "gyros_offset"); gyros_gains = new ReadOnlyItem<string>(this, "gyros_gains"); gyros110_offset = new ReadOnlyItem<string>(this, "gyros110_offset"); gyros110_gains = new ReadOnlyItem<string>(this, "gyros110_gains"); magneto_offset = new ReadOnlyItem<string>(this, "magneto_offset"); magneto_radius = new ReadOnlyItem<float>(this, "magneto_radius"); gyro_offset_thr_x = new ReadOnlyItem<float>(this, "gyro_offset_thr_x"); gyro_offset_thr_y = new ReadOnlyItem<float>(this, "gyro_offset_thr_y"); gyro_offset_thr_z = new ReadOnlyItem<float>(this, "gyro_offset_thr_z"); pwm_ref_gyros = new ReadOnlyItem<int>(this, "pwm_ref_gyros"); osctun_value = new ReadOnlyItem<int>(this, "osctun_value"); osctun_test = new ReadOnlyItem<bool>(this, "osctun_test"); control_level = new ActiveItem<int>(this, "control_level"); euler_angle_max = new ActiveItem<float>(this, "euler_angle_max"); altitude_max = new ActiveItem<int>(this, "altitude_max"); altitude_min = new ActiveItem<int>(this, "altitude_min"); control_iphone_tilt = new ActiveItem<float>(this, "control_iphone_tilt"); control_vz_max = new ActiveItem<float>(this, "control_vz_max"); control_yaw = new ActiveItem<float>(this, "control_yaw"); outdoor = new ActiveItem<bool>(this, "outdoor"); flight_without_shell = new ActiveItem<bool>(this, "flight_without_shell"); autonomous_flight = new ReadOnlyItem<bool>(this, "autonomous_flight"); // obsolete manual_trim = new ActiveItem<bool>(this, "manual_trim"); indoor_euler_angle_max = new ActiveItem<float>(this, "indoor_euler_angle_max"); indoor_control_vz_max = new ActiveItem<float>(this, "indoor_control_vz_max"); indoor_control_yaw = new ActiveItem<float>(this, "indoor_control_yaw"); outdoor_euler_angle_max = new ActiveItem<float>(this, "outdoor_euler_angle_max"); outdoor_control_vz_max = new ActiveItem<float>(this, "outdoor_control_vz_max"); outdoor_control_yaw = new ActiveItem<float>(this, "outdoor_control_yaw"); flying_mode = new ActiveItem<int>(this, "flying_mode"); hovering_range = new ActiveItem<int>(this, "hovering_range"); flight_anim = new FlightAnimationItem(this, "flight_anim"); }