Permalink
Browse files

Updated input project

  • Loading branch information...
theone1984 committed Jan 25, 2011
1 parent b962ac9 commit 452f1aa0fab6950b9f9c56276897a39bef52bcb8
Showing with 1,602 additions and 358 deletions.
  1. +1 −0 .gitignore
  2. +29 −0 ARDrone.sln
  3. +2 −1 ARDroneControlLibrary/ARDroneControl.cs
  4. +9 −6 ARDroneInput/ARDroneInput.csproj
  5. +2 −9 ARDroneInput/ButtonBasedInput.cs
  6. +20 −18 ARDroneInput/ConfigurableInput.cs
  7. +1 −1 ARDroneInput/GenericInput.cs
  8. +34 −0 ARDroneInput/InputConfigs/ButtonBasedInputConfig.cs
  9. +118 −0 ARDroneInput/InputConfigs/InputConfig.cs
  10. +41 −0 ARDroneInput/InputConfigs/SpeechBasedInputConfig.cs
  11. +12 −17 ARDroneInput/InputControls/ButtonBasedInputControl.cs
  12. +5 −4 ARDroneInput/InputControls/InputControl.cs
  13. +2 −0 ARDroneInput/InputControls/SpeechBasedInputControl.cs
  14. +7 −3 ARDroneInput/InputManager.cs
  15. +0 −5 ARDroneInput/InputMappings/ButtonBasedInputMapping.cs
  16. +9 −5 ARDroneInput/InputMappings/InputMapping.cs
  17. +177 −19 ARDroneInput/InputMappings/SpeechBasedInputMapping.cs
  18. +2 −1 ARDroneInput/InputMappings/ValidatedInputMapping.cs
  19. +2 −2 ARDroneInput/JoystickInput.cs
  20. +2 −1 ARDroneInput/KeyboardInput.cs
  21. +194 −0 ARDroneInput/Speech/SpeechRecognition.cs
  22. +121 −11 ARDroneInput/SpeechInput.cs
  23. +129 −0 ARDroneInput/Timing/TimeBasedCommand.cs
  24. +45 −0 ARDroneInput/Utility/InputFactory.cs
  25. +2 −1 ARDroneInput/WiimoteInput.cs
  26. +7 −53 ARDroneUI_WPF/ConfigInput.xaml
  27. +343 −201 ARDroneUI_WPF/ConfigInput.xaml.cs
  28. +66 −0 ARDrone_Testing/ARDrone_Testing.csproj
  29. +35 −0 ARDrone_Testing/Properties/AssemblyInfo.cs
  30. +81 −0 ARDrone_Testing/SpeechBasedInputMappingUnitTest.cs
  31. +73 −0 ARDrone_Testing/TimeBasedCommandUnitTest.cs
  32. +10 −0 Local.testsettings
  33. +21 −0 TraceAndTestImpact.testsettings
View
@@ -1,3 +1,4 @@
+TestResults
*.suo
*.sdf
*.ipch
View
@@ -31,11 +31,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ARDroneInput", "ARDroneInpu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7885A062-281E-475D-AE00-54D56221F433}"
ProjectSection(SolutionItems) = preProject
+ ARDrone.vsmdi = ARDrone.vsmdi
GNU GPL.txt = GNU GPL.txt
LibraryLicenses.txt = LibraryLicenses.txt
+ Local.testsettings = Local.testsettings
ParrotCopyrightAndDisclaimer.txt = ParrotCopyrightAndDisclaimer.txt
ParrotLicense.txt = ParrotLicense.txt
Readme.txt = Readme.txt
+ TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ARDroneCapture", "ARDroneCapture\ARDroneCapture.csproj", "{DF44B163-A438-4DCC-ADB0-5CDB08803A0F}"
@@ -54,7 +57,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectionControl", "Directi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ARDroneInput_Speech", "ARDroneInput_Speech\ARDroneInput_Speech.csproj", "{BE4A76AB-FA50-4E6D-BE06-D2D9A528DBB2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ARDrone_Testing", "ARDrone_Testing\ARDrone_Testing.csproj", "{EB016BB8-3E68-4DD7-B27E-317B18024FFA}"
+EndProject
Global
+ GlobalSection(TestCaseManagementSettings) = postSolution
+ CategoryFile = ARDrone.vsmdi
+ EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
@@ -388,6 +396,27 @@ Global
{BE4A76AB-FA50-4E6D-BE06-D2D9A528DBB2}.Release|Win32.ActiveCfg = Release|Any CPU
{BE4A76AB-FA50-4E6D-BE06-D2D9A528DBB2}.Release|x64.ActiveCfg = Release|Any CPU
{BE4A76AB-FA50-4E6D-BE06-D2D9A528DBB2}.Release|x86.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|Any CPU.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|Any CPU.Build.0 = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|Mixed Platforms.Build.0 = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|Win32.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|x64.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Profile|x86.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|Win32.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|x64.ActiveCfg = Release|Any CPU
+ {EB016BB8-3E68-4DD7-B27E-317B18024FFA}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -317,7 +317,8 @@ public DroneData GetCurrentDroneData()
if (isConnected)
{
- return new DroneData(GetDroneState(), GetBatteryLevel(), GetTheta(), GetPhi(), GetPsi(), GetAltitude(), GetVX(), GetVY(), GetVZ());
+ return new DroneData();
+ //return new DroneData(GetDroneState(), GetBatteryLevel(), GetTheta(), GetPhi(), GetPsi(), GetAltitude(), GetVX(), GetVY(), GetVZ());
}
else
{
@@ -47,6 +47,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
+ <Reference Include="System.Speech" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -60,14 +61,22 @@
<Compile Include="ButtonBasedInput.cs" />
<Compile Include="ConfigurableInput.cs" />
<Compile Include="DirectInputInput.cs" />
+ <Compile Include="InputConfigs\ButtonBasedInputConfig.cs" />
+ <Compile Include="InputConfigs\InputConfig.cs" />
+ <Compile Include="InputConfigs\SpeechBasedInputConfig.cs" />
<Compile Include="InputControls\ButtonBasedInputControl.cs" />
+ <Compile Include="InputControls\SpeechBasedInputControl.cs" />
<Compile Include="InputMappings\ButtonBasedInputMapping.cs" />
+ <Compile Include="InputMappings\SpeechBasedInputMapping.cs" />
+ <Compile Include="Timing\TimeBasedCommand.cs" />
+ <Compile Include="Speech\SpeechRecognition.cs" />
<Compile Include="Utility\Events.cs" />
<Compile Include="GenericInput.cs" />
<Compile Include="InputManager.cs" />
<Compile Include="InputMappings\ValidatedInputMapping.cs" />
<Compile Include="InputControls\InputControl.cs" />
<Compile Include="InputMappings\InputMapping.cs" />
+ <Compile Include="Utility\InputFactory.cs" />
<Compile Include="Utility\InputState.cs" />
<Compile Include="JoystickInput.cs" />
<Compile Include="KeyboardInput.cs" />
@@ -76,12 +85,6 @@
<Compile Include="Utility\DictionarySerializer.cs" />
<Compile Include="WiimoteInput.cs" />
</ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\ARDroneInput_Speech\ARDroneInput_Speech.csproj">
- <Project>{BE4A76AB-FA50-4E6D-BE06-D2D9A528DBB2}</Project>
- <Name>ARDroneInput_Speech</Name>
- </ProjectReference>
- </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -26,16 +26,9 @@ public abstract class ButtonBasedInput : ConfigurableInput
public ButtonBasedInput()
: base()
- {
-
- }
-
- protected override InputMapping GetMapping(List<String> validButtons, List<String> validAxes)
- {
- return new ButtonBasedInputMapping(validButtons, validAxes);
- }
+ { }
- public override void Init()
+ public override void InitDevice()
{
Dictionary<String, float> axisValues = GetAxisValues();
SetLastAxisValues(axisValues);
@@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Xml.Serialization;
+using ARDrone.Input.InputConfigs;
using ARDrone.Input.InputControls;
using ARDrone.Input.InputMappings;
using ARDrone.Input.Utility;
@@ -16,10 +17,20 @@ public abstract class ConfigurableInput : GenericInput
protected InputMapping mapping = null;
protected InputMapping backupMapping = null;
+ protected InputConfig inputConfig = null;
+
public ConfigurableInput()
: base()
{
- SetDefaultMapping();
+ inputConfig = InputFactory.CreateConfigFor(this);
+ }
+
+ public void DetermineMapping()
+ {
+ mapping = GetStandardMapping();
+ LoadMapping();
+
+ backupMapping = mapping.Clone();
}
public void SetDefaultMapping()
@@ -34,17 +45,7 @@ public void CopyMappingFrom(ConfigurableInput input)
backupMapping = input.backupMapping.Clone();
}
- protected void CreateMapping(List<String> validButtons, List<String> validAxes)
- {
- if (!LoadMapping())
- {
- GetMapping(validButtons, validAxes);
- }
- backupMapping = mapping.Clone();
- }
-
protected abstract InputMapping GetStandardMapping();
- protected abstract InputMapping GetMapping(List<String> validButtons, List<String> validAxes);
public bool LoadMapping()
{
@@ -84,13 +85,6 @@ public void SaveMapping()
String mappingFilePath = GetMappingFilePath();
DictionarySerializer.Serialize(mapping.Controls.Mappings, mappingFilePath);
-
- //XmlSerializer serializer = new XmlSerializer(typeof(Dictionary<String, String>));
- //using (System.IO.TextWriter textWriter = new System.IO.StreamWriter(mappingFilePath))
- //{
- // serializer.Serialize(textWriter, mapping.Controls.Mappings);
- // textWriter.Close();
- //}
}
catch (Exception e)
{
@@ -129,5 +123,13 @@ public virtual String FilePrefix
{
get { return string.Empty; }
}
+
+ public InputConfig InputConfig
+ {
+ get
+ {
+ return inputConfig;
+ }
+ }
}
}
@@ -15,7 +15,7 @@ namespace ARDrone.Input
{
public abstract class GenericInput
{
- public abstract void Init();
+ public abstract void InitDevice();
public abstract void Dispose();
public virtual void StartRawInput()
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ARDrone.Input.InputControls;
+
+namespace ARDrone.Input.InputConfigs
+{
+ public class ButtonBasedInputConfig : InputConfig
+ {
+ public ButtonBasedInputConfig()
+ : base()
+ {
+ SetStates();
+ }
+
+ private void SetStates()
+ {
+ states.Add("leftHeader", new InputConfigHeader("Axes", InputConfigState.Position.LeftColumn, 0));
+ states.Add(ButtonBasedInputControl.RollAxisField, new InputValueConfigState("Roll", InputConfigState.Position.LeftColumn, 1, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.ContinuousValue));
+ states.Add(ButtonBasedInputControl.PitchAxisField, new InputValueConfigState("Pitch", InputConfigState.Position.LeftColumn, 2, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.ContinuousValue));
+ states.Add(ButtonBasedInputControl.YawAxisField, new InputValueConfigState("Yaw", InputConfigState.Position.LeftColumn, 3, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.ContinuousValue));
+ states.Add(ButtonBasedInputControl.GazAxisField, new InputValueConfigState("Gaz", InputConfigState.Position.LeftColumn, 4, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.ContinuousValue));
+
+ states.Add("rightHeader", new InputConfigHeader("Buttons", InputConfigState.Position.RightColumn, 0));
+ states.Add(ButtonBasedInputControl.CameraSwapButtonField, new InputValueConfigState("Change Camera", InputConfigState.Position.RightColumn, 1, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.TakeOffButtonField, new InputValueConfigState("Take Off", InputConfigState.Position.RightColumn, 2, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.LandButtonField, new InputValueConfigState("Land", InputConfigState.Position.RightColumn, 3, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.HoverButtonField, new InputValueConfigState("Hover", InputConfigState.Position.RightColumn, 4, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.EmergencyButtonField, new InputValueConfigState("Emergency", InputConfigState.Position.RightColumn, 5, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.FlatTrimButtonField, new InputValueConfigState("Flat Trim", InputConfigState.Position.RightColumn, 6, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ states.Add(ButtonBasedInputControl.SpecialActionButtonField, new InputValueConfigState("Special Action", InputConfigState.Position.RightColumn, 7, InputValueConfigState.Mode.DisableOnInput, InputControl.ControlType.BooleanValue));
+ }
+ }
+}
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ARDrone.Input.InputControls;
+
+namespace ARDrone.Input.InputConfigs
+{
+ public class InputConfig
+ {
+ protected Dictionary<String, InputConfigState> states = new Dictionary<String, InputConfigState>();
+
+ private int GetMaxRowNumber()
+ {
+ int maxRowNumber = 0;
+ foreach (KeyValuePair<String, InputConfigState> entry in states)
+ {
+ if (entry.Value.RowNumber > maxRowNumber)
+ maxRowNumber = entry.Value.RowNumber;
+ }
+
+ return maxRowNumber;
+ }
+
+ public Dictionary<String, InputConfigState> States
+ {
+ get
+ {
+ return new Dictionary<String, InputConfigState>(states);
+ }
+ }
+
+ public int MaxRowNumber
+ {
+ get
+ {
+ return GetMaxRowNumber();
+ }
+ }
+ }
+
+ public abstract class InputConfigState
+ {
+ public enum Position { LeftColumn, RightColumn };
+
+ private Position layoutPosition;
+ private int rowNumber = 0;
+ private String name = "";
+
+ public InputConfigState(String name, Position layoutPosition, int rowNumber)
+ {
+ this.layoutPosition = layoutPosition;
+ this.rowNumber = rowNumber;
+ this.name = name;
+ }
+
+ public Position LayoutPosition
+ {
+ get
+ {
+ return layoutPosition;
+ }
+ }
+
+ public int RowNumber
+ {
+ get
+ {
+ return rowNumber;
+ }
+ }
+
+ public String Name
+ {
+ get
+ {
+ return name;
+ }
+ }
+ }
+
+ public class InputValueConfigState : InputConfigState
+ {
+ public enum Mode { DisableOnInput, DisableManually, DisableManuallyKeyboardAvailable };
+
+ private Mode inputMode;
+ private InputControl.ControlType inputValueType;
+
+ public InputValueConfigState(String name, Position layoutPosition, int rowNumber, Mode inputMode, InputControl.ControlType inputValueType)
+ : base(name, layoutPosition, rowNumber)
+ {
+ this.inputMode = inputMode;
+ this.inputValueType = inputValueType;
+ }
+
+ public Mode InputMode
+ {
+ get
+ {
+ return inputMode;
+ }
+ }
+
+ public InputControl.ControlType InputValueType
+ {
+ get
+ {
+ return inputValueType;
+ }
+ }
+ }
+
+ public class InputConfigHeader : InputConfigState
+ {
+ public InputConfigHeader(String name, Position layoutPosition, int rowNumber)
+ : base(name, layoutPosition, rowNumber)
+ { }
+ }
+}
Oops, something went wrong.

0 comments on commit 452f1aa

Please sign in to comment.