From a029de74a6c643e4b5d79d402ede96351fee8fe4 Mon Sep 17 00:00:00 2001 From: "Cameron (3539)" Date: Sun, 23 Jun 2024 23:01:58 -0400 Subject: [PATCH] Format and Clean Added formatting settings export --- Exported-2024-06-23.vssettings | 244 +++++++++ .../Motion-Profile-Mapper/Extensions.cs | 65 --- .../Motion-Profile-Mapper/Forms/AboutBox.cs | 76 +-- .../Forms/ConfigurationView.cs | 472 ++++++------------ .../Motion-Profile-Mapper/Forms/Menu.cs | 40 +- .../Motion-Profile-Mapper/Forms/MirrorPath.cs | 18 +- .../Forms/MotionProfiler.Designer.cs | 150 +++--- .../Forms/MotionProfiler.cs | 39 +- .../Forms/PathSettings.cs | 35 +- .../Forms/PoseVisualizer.Designer.cs | 176 ------- .../Forms/PoseVisualizer.cs | 104 ---- .../Forms/PoseVisualizer.resx | 197 -------- .../Motion-Profile-Mapper/Forms/Preview.cs | 9 +- .../Motion-Profile-Mapper/Forms/Settings.cs | 89 ++-- .../Motion-Profile-Mapper/Forms/ShiftPath.cs | 32 +- .../Motion-Profile-Mapper/Main/Program.cs | 33 +- .../MessageBoxManager.cs | 45 +- .../Motion-Profile-Mapper.csproj | 12 - .../Motion-Profile-Mapper/OutputPoints.cs | 6 +- .../Motion-Profile-Mapper/S_Curve.cs | 27 - .../SegmentedProfile/Profile.cs | 117 ++--- .../SegmentedProfile/ProfilePath.cs | 385 +++++--------- .../Motion-Profile-Mapper/Spline/ArrayUtil.cs | 53 +- .../Spline/ControlPoint.cs | 119 ++--- .../Spline/ControlPointSegment.cs | 6 +- .../Spline/SplinePath.cs | 57 +-- .../Spline/TriDiagonalMatrix.cs | 335 ++++++------- .../Motion-Profile-Mapper/UndoHolder.cs | 6 +- .../Motion-Profile-Mapper/Utilities/INI.cs | 168 +++---- .../Utilities/INIVariable.cs | 9 +- .../CentripetalAccelerationConstraint.cs | 23 +- .../VelocityGenerate/ConstrainedPathState.cs | 51 +- .../VelocityGenerate/MathUtil.cs | 54 +- .../VelocityGenerate/MathUtils.cs | 47 +- .../MaxAccelerationConstraint.cs | 20 +- .../VelocityGenerate/MaxVelocityContraint.cs | 22 +- .../VelocityGenerate/Path.cs | 27 +- .../VelocityGenerate/Pose2d.cs | 49 +- .../VelocityGenerate/Rotation2d.cs | 87 ++-- .../VelocityGenerate/TrajectoryConstraint.cs | 15 +- .../VelocityGenerate/Translation2d.cs | 70 +-- .../VelocityGenerate/Units.cs | 352 +++++++------ .../VelocityGenerate/VelocityGeneration.cs | 91 ++-- .../VelocityGenerator.cs | 251 ---------- 44 files changed, 1455 insertions(+), 2828 deletions(-) create mode 100644 Exported-2024-06-23.vssettings delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/Extensions.cs delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.Designer.cs delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.cs delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.resx delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/S_Curve.cs delete mode 100644 Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerator.cs diff --git a/Exported-2024-06-23.vssettings b/Exported-2024-06-23.vssettings new file mode 100644 index 0000000..0d3d5c5 --- /dev/null +++ b/Exported-2024-06-23.vssettings @@ -0,0 +1,244 @@ +4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />100101<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />111111-1<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />101<CodeStyleOption SerializationVersion="1" Type="String" Value="public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Int32" Value="2" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />11101<CodeStyleOption SerializationVersion="1" Type="Int32" Value="2" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />1000111<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />111011001<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />00001<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />100<NamingPreferencesInfo SerializationVersion="5"> + <SymbolSpecifications> + <SymbolSpecification ID="5c545a62-b14d-460a-88d8-e936c0a39316" Name="Class"> + <ApplicableSymbolKindList> + <TypeKind>Class</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="23d856b4-5089-4405-83ce-749aada99153" Name="Interface"> + <ApplicableSymbolKindList> + <TypeKind>Interface</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="d1796e78-ff66-463f-8576-eb46416060c0" Name="Struct"> + <ApplicableSymbolKindList> + <TypeKind>Struct</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="d8af8dc6-1ade-441d-9947-8946922e198a" Name="Enum"> + <ApplicableSymbolKindList> + <TypeKind>Enum</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="408a3347-b908-4b54-a954-1355e64c1de3" Name="Delegate"> + <ApplicableSymbolKindList> + <TypeKind>Delegate</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="830657f6-e7e5-4830-b328-f109d3b6c165" Name="Event"> + <ApplicableSymbolKindList> + <SymbolKind>Event</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="390caed4-f0a9-42bb-adbb-b44c4a302a22" Name="Method"> + <ApplicableSymbolKindList> + <MethodKind>Ordinary</MethodKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="af410767-f189-47c6-b140-aeccf1ff242e" Name="Private Method"> + <ApplicableSymbolKindList> + <MethodKind>Ordinary</MethodKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Private</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="8076757e-6a4a-47f1-9b4b-ae8a3284e987" Name="Abstract Method"> + <ApplicableSymbolKindList> + <MethodKind>Ordinary</MethodKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList> + <ModifierKind>IsAbstract</ModifierKind> + </RequiredModifierList> + </SymbolSpecification> + <SymbolSpecification ID="16133061-a8e7-4392-92c3-1d93cd54c218" Name="Static Method"> + <ApplicableSymbolKindList> + <MethodKind>Ordinary</MethodKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList> + <ModifierKind>IsStatic</ModifierKind> + </RequiredModifierList> + </SymbolSpecification> + <SymbolSpecification ID="da6a2919-5aa6-4ad1-a24d-576776ed3974" Name="Property"> + <ApplicableSymbolKindList> + <SymbolKind>Property</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="b24a91ce-3501-4799-b6df-baf044156c83" Name="Public or Protected Field"> + <ApplicableSymbolKindList> + <SymbolKind>Field</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="70af42cb-1741-4027-969c-9edc4877d965" Name="Static Field"> + <ApplicableSymbolKindList> + <SymbolKind>Field</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList> + <ModifierKind>IsStatic</ModifierKind> + </RequiredModifierList> + </SymbolSpecification> + <SymbolSpecification ID="10790aa6-0a0b-432d-a52d-d252ca92302b" Name="Private or Internal Field"> + <ApplicableSymbolKindList> + <SymbolKind>Field</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="ac995be4-88de-4771-9dcc-a456a7c02d89" Name="Private or Internal Static Field"> + <ApplicableSymbolKindList> + <SymbolKind>Field</SymbolKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList> + <ModifierKind>IsStatic</ModifierKind> + </RequiredModifierList> + </SymbolSpecification> + <SymbolSpecification ID="2c07f5bf-bc81-4c2b-82b4-ae9b3ffd0ba4" Name="Types"> + <ApplicableSymbolKindList> + <TypeKind>Class</TypeKind> + <TypeKind>Struct</TypeKind> + <TypeKind>Interface</TypeKind> + <TypeKind>Enum</TypeKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + <SymbolSpecification ID="5f3ddba1-279f-486c-801e-5c097c36dd85" Name="Non-Field Members"> + <ApplicableSymbolKindList> + <SymbolKind>Property</SymbolKind> + <SymbolKind>Event</SymbolKind> + <MethodKind>Ordinary</MethodKind> + </ApplicableSymbolKindList> + <ApplicableAccessibilityList> + <AccessibilityKind>Public</AccessibilityKind> + <AccessibilityKind>Internal</AccessibilityKind> + <AccessibilityKind>Private</AccessibilityKind> + <AccessibilityKind>Protected</AccessibilityKind> + <AccessibilityKind>ProtectedOrInternal</AccessibilityKind> + <AccessibilityKind>ProtectedAndInternal</AccessibilityKind> + </ApplicableAccessibilityList> + <RequiredModifierList /> + </SymbolSpecification> + </SymbolSpecifications> + <NamingStyles> + <NamingStyle ID="87e7c501-9948-4b53-b1eb-a6cbe918feee" Name="Pascal Case" Prefix="" Suffix="" WordSeparator="" CapitalizationScheme="PascalCase" /> + <NamingStyle ID="1ecc5eb6-b5fc-49a5-a9f1-a980f3e48c92" Name="Begins with I" Prefix="I" Suffix="" WordSeparator="" CapitalizationScheme="PascalCase" /> + </NamingStyles> + <NamingRules> + <SerializableNamingRule SymbolSpecificationID="23d856b4-5089-4405-83ce-749aada99153" NamingStyleID="1ecc5eb6-b5fc-49a5-a9f1-a980f3e48c92" EnforcementLevel="Info" /> + <SerializableNamingRule SymbolSpecificationID="2c07f5bf-bc81-4c2b-82b4-ae9b3ffd0ba4" NamingStyleID="87e7c501-9948-4b53-b1eb-a6cbe918feee" EnforcementLevel="Info" /> + <SerializableNamingRule SymbolSpecificationID="5f3ddba1-279f-486c-801e-5c097c36dd85" NamingStyleID="87e7c501-9948-4b53-b1eb-a6cbe918feee" EnforcementLevel="Info" /> + </NamingRules> +</NamingPreferencesInfo>0<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />001111001<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Int32" Value="2" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />001<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />10<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />0000010<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />1101001-1<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" />1010<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />000<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Info" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />010111001000111 \ No newline at end of file diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Extensions.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Extensions.cs deleted file mode 100644 index 2ccc7c0..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Extensions.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MotionProfileMapper -{ - public static class FloatExtension - { - public static void NoiseReduction(this float[] src, int severity = 1) - { - float[] ret = new float[src.Length]; - - for (int i = 1; i < src.Length; i++) - { - //---------------------------------------------------------------avg - var start = (i - severity > 0 ? i - severity : 0); - var end = (i + severity < src.Length ? i + severity : src.Length); - - float sum = 0; - - for (int j = start; j < end; j++) - { - sum += src[j]; - } - - var avg = sum / (end - start); - //--------------------------------------------------------------- - ret[i] = avg; - - } - for(int i = 1; i < src.Length; i++) - src[i] = ret[i]; - } - } - public static class ListExtention - { - public static void NoiseReduction(this List src, int severity = 1) - { - float[] ret = new float[src.Count]; - - for (int i = 1; i < src.Count; i++) - { - //---------------------------------------------------------------avg - var start = (i - severity > 0 ? i - severity : 0); - var end = (i + severity < src.Count ? i + severity : src.Count); - - float sum = 0; - - for (int j = start; j < end; j++) - { - sum += src[j]; - } - - var avg = sum / (end - start); - //--------------------------------------------------------------- - ret[i] = avg; - - } - for (int i = 1; i < src.Count; i++) - src[i] = ret[i]; - } - } -} diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/AboutBox.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/AboutBox.cs index d1fd473..46168f9 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/AboutBox.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/AboutBox.cs @@ -7,12 +7,9 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper -{ - partial class AboutBox : Form - { - public AboutBox() - { +namespace MotionProfileMapper { + partial class AboutBox : Form { + public AboutBox() { InitializeComponent(); this.Text = String.Format("About {0}", AssemblyTitle); this.labelProductName.Text = AssemblyProduct; @@ -24,16 +21,12 @@ public AboutBox() #region Assembly Attribute Accessors - public string AssemblyTitle - { - get - { + public string AssemblyTitle { + get { object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); - if (attributes.Length > 0) - { - AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; - if (titleAttribute.Title != "") - { + if (attributes.Length > 0) { + AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute) attributes[0]; + if (titleAttribute.Title != "") { return titleAttribute.Title; } } @@ -41,69 +34,54 @@ public string AssemblyTitle } } - public string AssemblyVersion - { - get - { + public string AssemblyVersion { + get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } } - public string AssemblyDescription - { - get - { + public string AssemblyDescription { + get { object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); - if (attributes.Length == 0) - { + if (attributes.Length == 0) { return ""; } - return ((AssemblyDescriptionAttribute)attributes[0]).Description; + return ( (AssemblyDescriptionAttribute) attributes[0] ).Description; } } - public string AssemblyProduct - { - get - { + public string AssemblyProduct { + get { object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); - if (attributes.Length == 0) - { + if (attributes.Length == 0) { return ""; } - return ((AssemblyProductAttribute)attributes[0]).Product; + return ( (AssemblyProductAttribute) attributes[0] ).Product; } } - public string AssemblyCopyright - { - get - { + public string AssemblyCopyright { + get { object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - if (attributes.Length == 0) - { + if (attributes.Length == 0) { return ""; } - return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + return ( (AssemblyCopyrightAttribute) attributes[0] ).Copyright; } } - public string AssemblyCompany - { - get - { + public string AssemblyCompany { + get { object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); - if (attributes.Length == 0) - { + if (attributes.Length == 0) { return ""; } - return ((AssemblyCompanyAttribute)attributes[0]).Company; + return ( (AssemblyCompanyAttribute) attributes[0] ).Company; } } #endregion - private void okButton_Click(object sender, EventArgs e) - { + private void okButton_Click(object sender, EventArgs e) { this.Close(); } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs index 9779913..8361071 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ConfigurationView.cs @@ -14,10 +14,8 @@ using MotionProfileMapper.Utilities; using System.Text.RegularExpressions; -namespace MotionProfileMapper.Forms -{ - public partial class ConfigurationView : Form - { +namespace MotionProfileMapper.Forms { + public partial class ConfigurationView : Form { private Menu menu; private OpenFileDialog fileDialog; @@ -39,52 +37,43 @@ public partial class ConfigurationView : Form "const", "float", "native", "super", "while" }; - public ConfigurationView(Menu menu) - { + public ConfigurationView(Menu menu) { this.menu = menu; InitializeComponent(); } - private void configurationGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) - { + private void configurationGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { List list = new List(); - for (int i = 0; i < configurationGrid.Rows.Count; i++) - { + for (int i = 0; i < configurationGrid.Rows.Count; i++) { DataGridViewRow row = configurationGrid.Rows[i]; if (row.Index == configurationGrid.RowCount - 1) continue; - if (row.Cells[1].EditedFormattedValue.ToString() == "boolean" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) - { + if (row.Cells[1].EditedFormattedValue.ToString() == "boolean" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) { DataGridViewCheckBoxCell cell = new DataGridViewCheckBoxCell(); cell.Value = false; row.Cells[2] = cell; } - if (row.Cells[1].EditedFormattedValue.ToString() == "int" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) - { + if (row.Cells[1].EditedFormattedValue.ToString() == "int" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = ""; row.Cells[2] = cell; } - if (row.Cells[1].EditedFormattedValue.ToString() == "double" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) - { + if (row.Cells[1].EditedFormattedValue.ToString() == "double" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = ""; row.Cells[2] = cell; } - if (row.Cells[1].EditedFormattedValue.ToString() == "String" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) - { + if (row.Cells[1].EditedFormattedValue.ToString() == "String" && !row.Cells[1].EditedFormattedValue.Equals(row.Cells[1].Value)) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); cell.Value = ""; row.Cells[2] = cell; } - if (javaKeywords.Contains(row.Cells[0].EditedFormattedValue.ToString().ToLower())) - { + if (javaKeywords.Contains(row.Cells[0].EditedFormattedValue.ToString().ToLower())) { row.ErrorText = "Variable name is a keyword in java"; - } - else if (Regex.IsMatch(row.Cells[0].EditedFormattedValue.ToString().ToLower(), @"^\d")) + } else if (Regex.IsMatch(row.Cells[0].EditedFormattedValue.ToString().ToLower(), @"^\d")) row.ErrorText = "Name may not start with a number"; else if (Regex.IsMatch(row.Cells[0].EditedFormattedValue.ToString().ToLower(), @"[^a-zA-Z0-9\s]")) row.ErrorText = "Name may not contain special characters"; @@ -102,10 +91,8 @@ private void configurationGrid_CellValidating(object sender, DataGridViewCellVal list.Add(row.Cells[0].EditedFormattedValue.ToString()); } } - private void configurationGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) - { - if (configurationGrid.CurrentCell == null) - { + private void configurationGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { + if (configurationGrid.CurrentCell == null) { return; } e.Control.KeyPress -= new KeyPressEventHandler(Column3_KeyPress_NULL); @@ -117,141 +104,109 @@ private void configurationGrid_EditingControlShowing(object sender, DataGridView e.Control.KeyDown -= new KeyEventHandler(Column3_KeyDown_Double); - if (configurationGrid.CurrentCell.ColumnIndex == 0) - { + if (configurationGrid.CurrentCell.ColumnIndex == 0) { TextBox tb = e.Control as TextBox; - if (tb != null) - { + if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column3_KeyPress_VariableName); } } - if (configurationGrid.CurrentCell.ColumnIndex == 2) - { - if (configurationGrid.CurrentRow.Cells[1].Value == null) - { + if (configurationGrid.CurrentCell.ColumnIndex == 2) { + if (configurationGrid.CurrentRow.Cells[1].Value == null) { TextBox tb = e.Control as TextBox; - if (tb != null) - { + if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column3_KeyPress_NULL); } - } - else if (configurationGrid.CurrentRow.Cells[1].Value.ToString() == "int") - { + } else if (configurationGrid.CurrentRow.Cells[1].Value.ToString() == "int") { TextBox tb = e.Control as TextBox; - if (tb != null) - { + if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column3_KeyPress_Int); tb.KeyDown += new KeyEventHandler(Column3_KeyDown_Int); } - } - else if (configurationGrid.CurrentRow.Cells[1].Value.ToString() == "double") - { + } else if (configurationGrid.CurrentRow.Cells[1].Value.ToString() == "double") { TextBox tb = e.Control as TextBox; - if (tb != null) - { + if (tb != null) { tb.KeyPress += new KeyPressEventHandler(Column3_KeyPress_Double); tb.KeyDown += new KeyEventHandler(Column3_KeyDown_Double); } } } } - private void Column3_KeyDown_Double(object sender, KeyEventArgs e) - { - if (e.Control && e.KeyCode == Keys.V) - { + private void Column3_KeyDown_Double(object sender, KeyEventArgs e) { + if (e.Control && e.KeyCode == Keys.V) { double output; - if (!double.TryParse(Clipboard.GetText(), out output)) - { + if (!double.TryParse(Clipboard.GetText(), out output)) { e.Handled = true; e.SuppressKeyPress = true; } } } - private void Column3_KeyDown_Int(object sender, KeyEventArgs e) - { + private void Column3_KeyDown_Int(object sender, KeyEventArgs e) { - if (e.Control && e.KeyCode == Keys.V) - { + if (e.Control && e.KeyCode == Keys.V) { int output; - if (!int.TryParse(Clipboard.GetText(), out output)) - { + if (!int.TryParse(Clipboard.GetText(), out output)) { e.Handled = true; e.SuppressKeyPress = true; } } } - private void Column3_KeyPress_Double(object sender, KeyPressEventArgs e) - { + private void Column3_KeyPress_Double(object sender, KeyPressEventArgs e) { // allows 0-9, backspace, and decimal - if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 46 && e.KeyChar != '-' && !char.IsControl(e.KeyChar))) - { + if (( ( e.KeyChar < 48 || e.KeyChar > 57 ) && e.KeyChar != 8 && e.KeyChar != 46 && e.KeyChar != '-' && !char.IsControl(e.KeyChar) )) { e.Handled = true; return; } // checks to make sure only 1 decimal is allowed - if (e.KeyChar == 46) - { - if ((sender as TextBox).Text.IndexOf(e.KeyChar) != -1) + if (e.KeyChar == 46) { + if (( sender as TextBox ).Text.IndexOf(e.KeyChar) != -1) e.Handled = true; } // checks to make sure only 1 - is allowed - if (e.KeyChar == '-') - { - if ((sender as TextBox).SelectionStart != 0) + if (e.KeyChar == '-') { + if (( sender as TextBox ).SelectionStart != 0) e.Handled = true; - if ((sender as TextBox).Text.IndexOf(e.KeyChar) != -1) + if (( sender as TextBox ).Text.IndexOf(e.KeyChar) != -1) e.Handled = true; } } - private void Column3_KeyPress_VariableName(object sender, KeyPressEventArgs e) - { - if ((sender as TextBox).TextLength == 0) - { - if (!char.IsLetter(e.KeyChar) && !char.IsControl(e.KeyChar)) - { + private void Column3_KeyPress_VariableName(object sender, KeyPressEventArgs e) { + if (( sender as TextBox ).TextLength == 0) { + if (!char.IsLetter(e.KeyChar) && !char.IsControl(e.KeyChar)) { e.Handled = true; } } } - private void Column3_KeyPress_NULL(object sender, KeyPressEventArgs e) - { + private void Column3_KeyPress_NULL(object sender, KeyPressEventArgs e) { e.Handled = true; } - private void Column3_KeyPress_Int(object sender, KeyPressEventArgs e) - { + private void Column3_KeyPress_Int(object sender, KeyPressEventArgs e) { // checks to make sure only 1 decimal is allowed - if (e.KeyChar == 46) - { + if (e.KeyChar == 46) { MessageBox.Show("Did you mean to use Double? Integers can't contain a '.'", "Wrong Type", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // allows 0-9, backspace, and decimal - if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != '-' && !char.IsControl(e.KeyChar))) - { + if (( ( e.KeyChar < 48 || e.KeyChar > 57 ) && e.KeyChar != 8 && e.KeyChar != '-' && !char.IsControl(e.KeyChar) )) { e.Handled = true; return; } // checks to make sure only 1 - is allowed - if (e.KeyChar == '-') - { - if ((sender as TextBox).SelectionStart != 0) + if (e.KeyChar == '-') { + if (( sender as TextBox ).SelectionStart != 0) e.Handled = true; - if ((sender as TextBox).Text.IndexOf(e.KeyChar) != -1) + if (( sender as TextBox ).Text.IndexOf(e.KeyChar) != -1) e.Handled = true; } } - private Boolean checkForDuplicateNames() - { + private Boolean checkForDuplicateNames() { List names = new List(); - foreach (INI ini in inis) - { - if (names.Contains(ini.fileName)) - { + foreach (INI ini in inis) { + if (names.Contains(ini.fileName)) { MessageBox.Show($"There are two or more files named {ini.fileName}", "Duplicate File Names", MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; } @@ -260,32 +215,25 @@ private Boolean checkForDuplicateNames() } return false; } - private Boolean checkForVariableValues() - { - foreach (INI ini in inis) - { + private Boolean checkForVariableValues() { + foreach (INI ini in inis) { if (ini.checkValues()) return true; } return false; } - private Boolean checkForVariableType() - { - foreach (INI ini in inis) - { + private Boolean checkForVariableType() { + foreach (INI ini in inis) { if (ini.checkVariableTypes()) return true; } return false; } - private Boolean checkForVariableNames() - { - foreach (INI ini in inis) - { + private Boolean checkForVariableNames() { + foreach (INI ini in inis) { if (ini.checkVariableNames()) return true; } return false; } - private Boolean validateINIS() - { + private Boolean validateINIS() { if (checkForVariableNames()) return true; if (checkForDuplicateNames()) return true; if (checkForVariableType()) return true; @@ -293,15 +241,13 @@ private Boolean validateINIS() return false; } - private void saveAllLocalButton_Click(object sender, EventArgs e) - { + private void saveAllLocalButton_Click(object sender, EventArgs e) { if (validateINIS()) return; SaveFileDialog browser = new SaveFileDialog(); browser.RestoreDirectory = true; String files = ""; - foreach (INI ini in inis) - { + foreach (INI ini in inis) { files += $"\"{ini.fileName}\" "; } @@ -313,19 +259,16 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) String iniBasePath = ""; String javaBasePath = ""; - if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) - { + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) { if (browser.ShowDialog() != DialogResult.OK) return; iniBasePath = Path.GetDirectoryName(browser.FileName.Trim()); javaBasePath = iniBasePath; - } - else - { + } else { iniBasePath = Properties.Settings.Default.iniSavePath; javaBasePath = Properties.Settings.Default.javaSavePath; } - Cursor = Cursors.WaitCursor; + Cursor = Cursors.WaitCursor; setStatus("Saving profiles to file system...", Color.Black); List paths = new List(); @@ -333,23 +276,17 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) - foreach (INI ini in inis) - { + foreach (INI ini in inis) { string iniPath = Path.Combine(iniBasePath, Path.GetFileNameWithoutExtension(ini.fileName) + ".ini"); string javaPath = Path.Combine(javaBasePath, Path.GetFileNameWithoutExtension(ini.fileName) + ".java"); - - if (browser.FilterIndex == 2) - { + + if (browser.FilterIndex == 2) { paths.Add(iniPath); iniList.Add(ini); - } - else if (browser.FilterIndex == 3) - { + } else if (browser.FilterIndex == 3) { paths.Add(javaPath); iniList.Add(ini); - } - else - { + } else { paths.Add(javaPath); iniList.Add(ini); paths.Add(iniPath); @@ -357,13 +294,11 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) } } bool yesToAll = false; - for (int i = 0; i < paths.Count; i++) - { + for (int i = 0; i < paths.Count; i++) { string path = paths[i]; INI ini = iniList[i]; string filePath = path; - if (File.Exists(filePath) && !yesToAll) - { + if (File.Exists(filePath) && !yesToAll) { MessageBoxManager.Yes = "Yes"; MessageBoxManager.No = "No"; MessageBoxManager.Cancel = "Yes To All"; @@ -371,8 +306,7 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) DialogResult result = MessageBox.Show($"{path} already exists. \nDo you want to replace it?", "Confirm Save As", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); MessageBoxManager.Unregister(); - switch (result) - { + switch (result) { case DialogResult.OK: break; case DialogResult.No: @@ -384,13 +318,11 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) } if (Path.GetExtension(path) == ".ini") - using (var writer = new StreamWriter(filePath)) - { + using (var writer = new StreamWriter(filePath)) { writer.Write(ini.toIni()); } if (Path.GetExtension(path) == ".java") - using (var writer = new StreamWriter(filePath)) - { + using (var writer = new StreamWriter(filePath)) { writer.Write(ini.toJava()); } } @@ -400,8 +332,7 @@ private void saveAllLocalButton_Click(object sender, EventArgs e) setStatus("Configure Robot Constants", Color.Black); Cursor = Cursors.Default; } - private void saveLocalButton_Click(object sender, EventArgs e) - { + private void saveLocalButton_Click(object sender, EventArgs e) { if (validateINIS()) return; if (selectedIni == null) @@ -417,14 +348,11 @@ private void saveLocalButton_Click(object sender, EventArgs e) String iniBasePath = ""; String javaBasePath = ""; - if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) - { + if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) { if (browser.ShowDialog() != DialogResult.OK) return; iniBasePath = Path.GetDirectoryName(browser.FileName.Trim()); javaBasePath = iniBasePath; - } - else - { + } else { iniBasePath = Properties.Settings.Default.iniSavePath; javaBasePath = Properties.Settings.Default.javaSavePath; } @@ -444,27 +372,23 @@ private void saveLocalButton_Click(object sender, EventArgs e) paths.Add(iniPath); else if (browser.FilterIndex == 3) paths.Add(javaPath); - else - { + else { paths.Add(javaPath); paths.Add(iniPath); } bool yesToAll = false; - foreach (string path in paths) - { + foreach (string path in paths) { string filePath = path; - if (File.Exists(filePath) && !yesToAll) - { + if (File.Exists(filePath) && !yesToAll) { MessageBoxManager.Yes = "Yes"; MessageBoxManager.No = "No"; MessageBoxManager.Cancel = "Yes To All"; MessageBoxManager.Register(); DialogResult result = MessageBox.Show($"{path} already exists. \nDo you want to replace it?", "Confirm Save As", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); MessageBoxManager.Unregister(); - switch (result) - { + switch (result) { case DialogResult.OK: break; case DialogResult.No: @@ -476,25 +400,21 @@ private void saveLocalButton_Click(object sender, EventArgs e) } if (Path.GetExtension(path) == ".ini") - using (var writer = new StreamWriter(filePath)) - { + using (var writer = new StreamWriter(filePath)) { writer.Write(selectedIni.toIni()); } if (Path.GetExtension(path) == ".java") - using (var writer = new StreamWriter(filePath)) - { + using (var writer = new StreamWriter(filePath)) { writer.Write(selectedIni.toJava()); } } Cursor = Cursors.Default; } - private void saveToRioButton_Click(object sender, EventArgs e) - { + private void saveToRioButton_Click(object sender, EventArgs e) { if (validateINIS()) return; - if (inis.Count == 0) - { + if (inis.Count == 0) { setStatus("No INIs to save to RIO", Color.Red); return; } @@ -512,8 +432,7 @@ private void saveToRioButton_Click(object sender, EventArgs e) SftpClient sftp = new SftpClient(info); - try - { + try { setStatus("Establishing RIO connection...", Color.Black); sftp.Connect(); @@ -521,10 +440,8 @@ private void saveToRioButton_Click(object sender, EventArgs e) if (!sftp.Exists(Properties.Settings.Default.INILocation)) sftp.CreateDirectory(Properties.Settings.Default.INILocation); List invalidINIs = new List(); - foreach (INI ini in inis) - { - if (!ini.isValid()) - { + foreach (INI ini in inis) { + if (!ini.isValid()) { invalidINIs.Add(ini); continue; } @@ -538,8 +455,7 @@ private void saveToRioButton_Click(object sender, EventArgs e) setStatus("Verifying file contents...", Color.Black); bool verified = true; - foreach (INI ini in inis) - { + foreach (INI ini in inis) { if (invalidINIs.Contains(ini)) continue; StreamReader reader = sftp.OpenText( Path.Combine(Properties.Settings.Default.INILocation, ini.fileName.Replace(' ', '_') + ".ini") @@ -554,37 +470,25 @@ private void saveToRioButton_Click(object sender, EventArgs e) MessageBoxIcon.Warning ); - if (verified) - { + if (verified) { setStatus("INI(s) uploaded and verified successfully", Color.Green); timer1.Enabled = true; timeOfUpload = DateTime.Now; - } - else setStatus("Failed to verify uploaded file content", Color.Red); + } else setStatus("Failed to verify uploaded file content", Color.Red); sftp.Disconnect(); - } - catch (Renci.SshNet.Common.SshConnectionException exception) - { + } catch (Renci.SshNet.Common.SshConnectionException exception) { Console.WriteLine("SshConnectionException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (Renci.SshNet.Common.SshOperationTimeoutException exception) - { + } catch (Renci.SshNet.Common.SshOperationTimeoutException exception) { Console.WriteLine("SshConnectionException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (System.Net.Sockets.SocketException exception) - { + } catch (System.Net.Sockets.SocketException exception) { Console.WriteLine("SocketException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (Renci.SshNet.Common.SftpPermissionDeniedException exception) - { + } catch (Renci.SshNet.Common.SftpPermissionDeniedException exception) { Console.WriteLine("SftpPermissionDeniedException, source: {0}", exception.StackTrace); setStatus("Permission denied", Color.Red); - } - catch (Exception exception) - { + } catch (Exception exception) { Console.WriteLine("Exception, source: {0}", exception.StackTrace); setStatus("Failed to upload INI to RIO", Color.Red); } @@ -592,8 +496,7 @@ private void saveToRioButton_Click(object sender, EventArgs e) Cursor = Cursors.Default; } - private void loadRIOButton_Click(object sender, EventArgs e) - { + private void loadRIOButton_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; ConnectionInfo info = new ConnectionInfo( Properties.Settings.Default.IpAddress, @@ -611,26 +514,22 @@ private void loadRIOButton_Click(object sender, EventArgs e) Properties.Settings.Default.Username, Properties.Settings.Default.Password );*/ - try - { + try { setStatus("Establishing RIO connection...", Color.Black); sftp.Connect(); - if (!sftp.Exists(Properties.Settings.Default.INILocation)) - { + if (!sftp.Exists(Properties.Settings.Default.INILocation)) { sftp.CreateDirectory(Properties.Settings.Default.INILocation); setStatus("No INI files found at RIO directory", Color.Black); return; } bool foundFiles = false; - foreach (SftpFile file in sftp.ListDirectory(Properties.Settings.Default.INILocation)) - { + foreach (SftpFile file in sftp.ListDirectory(Properties.Settings.Default.INILocation)) { if (!file.Name.EndsWith(".ini")) continue; foundFiles = true; - using (StreamReader reader = sftp.OpenText(file.FullName)) - { + using (StreamReader reader = sftp.OpenText(file.FullName)) { addFile(new INI(Path.GetFileNameWithoutExtension(file.Name), reader)); } } @@ -638,29 +537,19 @@ private void loadRIOButton_Click(object sender, EventArgs e) else setStatus("No INI files found at RIO directory", Color.Black); sftp.Disconnect(); - } - catch (Renci.SshNet.Common.SshConnectionException exception) - { + } catch (Renci.SshNet.Common.SshConnectionException exception) { Console.WriteLine("SshConnectionException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (Renci.SshNet.Common.SshOperationTimeoutException exception) - { + } catch (Renci.SshNet.Common.SshOperationTimeoutException exception) { Console.WriteLine("SshConnectionException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (System.Net.Sockets.SocketException exception) - { + } catch (System.Net.Sockets.SocketException exception) { Console.WriteLine("SocketException, source: {0}", exception.StackTrace); setStatus("Failed to establish connection", Color.Red); - } - catch (Renci.SshNet.Common.SftpPermissionDeniedException exception) - { + } catch (Renci.SshNet.Common.SftpPermissionDeniedException exception) { Console.WriteLine("SftpPermissionDeniedException, source: {0}", exception.StackTrace); setStatus("Permission denied", Color.Red); - } - catch (Exception exception) - { + } catch (Exception exception) { Console.WriteLine("Exception, source: {0}", exception.StackTrace); setStatus("Failed to load INI files", Color.Red); } @@ -668,13 +557,11 @@ private void loadRIOButton_Click(object sender, EventArgs e) Cursor = Cursors.Default; } - private void ConfigurationView_FormClosed(object sender, FormClosedEventArgs e) - { + private void ConfigurationView_FormClosed(object sender, FormClosedEventArgs e) { this.menu.Close(); } - private void loadLocalButton_Click(object sender, EventArgs e) - { + private void loadLocalButton_Click(object sender, EventArgs e) { fileDialog = new OpenFileDialog(); fileDialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); fileDialog.FileName = ""; @@ -682,41 +569,33 @@ private void loadLocalButton_Click(object sender, EventArgs e) fileDialog.Title = "Select initialization files to load"; fileDialog.Multiselect = true; - if (Directory.Exists(Properties.Settings.Default.iniSavePath)) - { + if (Directory.Exists(Properties.Settings.Default.iniSavePath)) { fileDialog.InitialDirectory = Properties.Settings.Default.iniSavePath; } if (fileDialog.ShowDialog() != DialogResult.OK) return; Cursor = Cursors.WaitCursor; - foreach (string filename in fileDialog.FileNames) - { - using (System.IO.StreamReader fileReader = new System.IO.StreamReader(filename)) - { - try - { + foreach (string filename in fileDialog.FileNames) { + using (System.IO.StreamReader fileReader = new System.IO.StreamReader(filename)) { + try { addFile(new INI(Path.GetFileNameWithoutExtension(filename), fileReader)); - } - catch - { + } catch { MessageBox.Show("Error loading file " + filename, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - if(inis.Count>0) - { + if (inis.Count > 0) { inis.Last().loadTable(configurationGrid); filenameGrid.ClearSelection(); - filenameGrid.Rows[filenameGrid.Rows.Count-1].Selected = true; + filenameGrid.Rows[filenameGrid.Rows.Count - 1].Selected = true; selectedIni = inis.Last(); checkEnableStatuses(); } - + Cursor = Cursors.Default; } - private void checkEnableStatuses() - { + private void checkEnableStatuses() { saveToRioButton.Enabled = inis.Count > 0; saveLocalButton.Enabled = selectedIni != null; saveAllLocalButton.Enabled = inis.Count > 0; @@ -724,46 +603,39 @@ private void checkEnableStatuses() configurationGrid.Enabled = filenameGrid.SelectedCells.Count > 0; if (configurationGrid.Enabled) configurationGrid_CellValidating(null, null); - else - { + else { configurationGrid.Rows.Clear(); } } - private void filenameGrid_RowEnter(object sender, DataGridViewCellEventArgs e) - { + private void filenameGrid_RowEnter(object sender, DataGridViewCellEventArgs e) { inis[e.RowIndex].loadTable(configurationGrid); selectedIni = inis[e.RowIndex]; checkEnableStatuses(); } - private void configurationGrid_CellValidated(object sender, DataGridViewCellEventArgs e) - { + private void configurationGrid_CellValidated(object sender, DataGridViewCellEventArgs e) { if (configurationGrid.SelectedCells.Count == 0 || e.RowIndex == configurationGrid.RowCount - 1) return; - if (e.RowIndex == selectedIni.variables.Count) - { + if (e.RowIndex == selectedIni.variables.Count) { selectedIni.addVariable(""); } int index = configurationGrid.SelectedCells[0].RowIndex; selectedIni.updateVariable(e.RowIndex, tryToString(configurationGrid.Rows[index].Cells[0].Value), tryToString(configurationGrid.Rows[index].Cells[1].Value), tryToString(configurationGrid.Rows[index].Cells[2].Value), tryToString(configurationGrid.Rows[index].Cells[3].Value)); } - private void filenameGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) - { + private void filenameGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewCell cell = filenameGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.Value = cell.Value.ToString().Replace(" ", ""); if (cell.Value.ToString().Length == 0) cell.Value = inis[e.RowIndex].fileName; - else - { + else { inis[e.RowIndex].fileName = cell.Value.ToString(); } } - private void connectionSettingsButton_Click(object sender, EventArgs e) - { + private void connectionSettingsButton_Click(object sender, EventArgs e) { Settings settings = new Settings(); settings.Show(); } @@ -771,13 +643,11 @@ private void connectionSettingsButton_Click(object sender, EventArgs e) /// /// Set the status message at the top of the field display /// - private void setStatus(string message, Color color) - { + private void setStatus(string message, Color color) { infoLabel.Text = message; infoLabel.ForeColor = color; } - private void addFile(INI ini) - { + private void addFile(INI ini) { inis.Add(ini); int rowIndex = filenameGrid.Rows.Add(inis.Last()); inis.Last().loadTable(configurationGrid); @@ -786,21 +656,16 @@ private void addFile(INI ini) filenameGrid.Rows[rowIndex].Selected = true; checkEnableStatuses(); } - private void removeFile(int index) - { + private void removeFile(int index) { inis.RemoveAt(index); filenameGrid.Rows.RemoveAt(index); - if (filenameGrid.RowCount > 0) - { + if (filenameGrid.RowCount > 0) { filenameGrid.ClearSelection(); - if (index > 0) - { + if (index > 0) { filenameGrid.Rows[index - 1].Selected = true; inis[index - 1].loadTable(configurationGrid); selectedIni = inis[index - 1]; - } - else - { + } else { filenameGrid.Rows[0].Selected = true; inis[index].loadTable(configurationGrid); selectedIni = inis[index]; @@ -808,24 +673,20 @@ private void removeFile(int index) } checkEnableStatuses(); } - private void newFileButton_Click(object sender, EventArgs e) - { + private void newFileButton_Click(object sender, EventArgs e) { addFile(new INI()); } - private void configurationGrid_UserDeletedRow(object sender, DataGridViewRowEventArgs e) - { + private void configurationGrid_UserDeletedRow(object sender, DataGridViewRowEventArgs e) { reloadVariablesFromTable(); } - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) - { + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { configurationGrid.Rows.Remove(configurationGrid.SelectedRows[0]); reloadVariablesFromTable(); } - private void deleteButton_Click(object sender, EventArgs e) - { - if(filenameGrid.SelectedCells.Count>0) + private void deleteButton_Click(object sender, EventArgs e) { + if (filenameGrid.SelectedCells.Count > 0) removeFile(filenameGrid.SelectedCells[0].RowIndex); } @@ -833,14 +694,11 @@ private void deleteButton_Click(object sender, EventArgs e) private int rowIndexFromMouseDown; private int rowIndexOfItemUnderMouseToDrop; - private void configurationGrid_MouseMove(object sender, MouseEventArgs e) - { - if ((e.Button & MouseButtons.Left) == MouseButtons.Left) - { + private void configurationGrid_MouseMove(object sender, MouseEventArgs e) { + if (( e.Button & MouseButtons.Left ) == MouseButtons.Left) { // If the mouse moves outside the rectangle, start the drag. if (dragBoxFromMouseDown != Rectangle.Empty && - !dragBoxFromMouseDown.Contains(e.X, e.Y)) - { + !dragBoxFromMouseDown.Contains(e.X, e.Y)) { // Proceed with the drag and drop, passing in the list item. DragDropEffects dropEffect = configurationGrid.DoDragDrop( configurationGrid.Rows[rowIndexFromMouseDown], @@ -849,13 +707,11 @@ private void configurationGrid_MouseMove(object sender, MouseEventArgs e) } } - private void configurationGrid_MouseDown(object sender, MouseEventArgs e) - { + private void configurationGrid_MouseDown(object sender, MouseEventArgs e) { // Get the index of the item the mouse is below. rowIndexFromMouseDown = configurationGrid.HitTest(e.X, e.Y).RowIndex; - if (rowIndexFromMouseDown != -1) - { + if (rowIndexFromMouseDown != -1) { // Remember the point where the mouse down occurred. // The DragSize indicates the size that the mouse can move // before a drag event should be started. @@ -865,30 +721,25 @@ private void configurationGrid_MouseDown(object sender, MouseEventArgs e) // at the center of the rectangle. dragBoxFromMouseDown = new Rectangle( new Point( - e.X - (dragSize.Width / 2), - e.Y - (dragSize.Height / 2)), + e.X - ( dragSize.Width / 2 ), + e.Y - ( dragSize.Height / 2 )), dragSize); - } - else + } else // Reset the rectangle if the mouse is not over an item in the ListBox. dragBoxFromMouseDown = Rectangle.Empty; } - private void configurationGrid_DragOver(object sender, DragEventArgs e) - { + private void configurationGrid_DragOver(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Move; } - private void reloadVariablesFromTable() - { + private void reloadVariablesFromTable() { selectedIni.clearVariables(); - foreach (DataGridViewRow row in configurationGrid.Rows) - { + foreach (DataGridViewRow row in configurationGrid.Rows) { if (row.Index >= configurationGrid.RowCount - 1) continue; selectedIni.addVariable(tryToString(row.Cells[0].Value), tryToString(row.Cells[1].Value), tryToString(row.Cells[2].Value)); } } - private void configurationGrid_DragDrop(object sender, DragEventArgs e) - { + private void configurationGrid_DragDrop(object sender, DragEventArgs e) { // The mouse locations are relative to the screen, so they must be // converted to client coordinates. Point clientPoint = configurationGrid.PointToClient(new Point(e.X, e.Y)); @@ -896,53 +747,42 @@ private void configurationGrid_DragDrop(object sender, DragEventArgs e) // Get the row index of the item the mouse is below. rowIndexOfItemUnderMouseToDrop = configurationGrid.HitTest(clientPoint.X, clientPoint.Y).RowIndex; - if(!(rowIndexOfItemUnderMouseToDrop>=0) || !(rowIndexOfItemUnderMouseToDrop= 0 ) || !( rowIndexOfItemUnderMouseToDrop < configurationGrid.Rows.Count )) { return; } // If the drag operation was a move then remove and insert the row. - if (e.Effect == DragDropEffects.Move) - { + if (e.Effect == DragDropEffects.Move) { DataGridViewRow rowToMove = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow; configurationGrid.Rows.RemoveAt(rowIndexFromMouseDown); - if(configurationGrid.Rows.Count<= rowIndexOfItemUnderMouseToDrop) - { + if (configurationGrid.Rows.Count <= rowIndexOfItemUnderMouseToDrop) { configurationGrid.Rows.Add(rowToMove); - } - else - { + } else { configurationGrid.Rows.Insert(rowIndexOfItemUnderMouseToDrop, rowToMove); } } reloadVariablesFromTable(); } - private String tryToString(object o) - { - if (o != null) - { + private String tryToString(object o) { + if (o != null) { return o.ToString(); } return ""; } - private void configurationGrid_Sorted(object sender, EventArgs e) - { + private void configurationGrid_Sorted(object sender, EventArgs e) { reloadVariablesFromTable(); } - private void rowContextMenuStrip_Opening(object sender, CancelEventArgs e) - { + private void rowContextMenuStrip_Opening(object sender, CancelEventArgs e) { if (configurationGrid.SelectedRows.Count < 1) { e.Cancel = true; return; } if (configurationGrid.SelectedRows[0].Index == configurationGrid.RowCount - 1) e.Cancel = true; } - private void configurationGrid_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { + private void configurationGrid_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { + if (e.Button == MouseButtons.Right) { configurationGrid.ClearSelection(); configurationGrid.Rows[e.RowIndex].Selected = true; @@ -952,16 +792,14 @@ private void configurationGrid_RowHeaderMouseClick(object sender, DataGridViewCe } } - private void timer1_Tick(object sender, EventArgs e) - { + private void timer1_Tick(object sender, EventArgs e) { TimeSpan ts = DateTime.Now - timeOfUpload; timeSinceUpload.Text = "Last Upload: " + ts.ToString("h'h 'm'm 's's'"); } - private void iconButton2_Click(object sender, EventArgs e) - { + private void iconButton2_Click(object sender, EventArgs e) { menu.mp.Show(); this.Hide(); } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Menu.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Menu.cs index f7f5a80..02f0c88 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Menu.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Menu.cs @@ -11,23 +11,19 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Forms -{ - public partial class Menu : Form - { +namespace MotionProfileMapper.Forms { + public partial class Menu : Form { public MotionProfileMapper.MotionProfiler mp; public ConfigurationView constants; - public Menu() - { + public Menu() { mp = new MotionProfileMapper.MotionProfiler(this); constants = new ConfigurationView(this); InitializeComponent(); bool internet = checkForInternet(); - if (Properties.Settings.Default.autoCheckForUpdates && internet) - { + if (Properties.Settings.Default.autoCheckForUpdates && internet) { GitHubClient client = new GitHubClient(new ProductHeaderValue("Motion-Profile-Mapper", System.Windows.Forms.Application.ProductVersion)); Task task = client.Repository.Release.GetLatest("BytingBulldogs3539", "Motion-Profile-Mapper"); @@ -41,50 +37,40 @@ public Menu() //Compare the Versions //Source: https://stackoverflow.com/questions/7568147/compare-version-numbers-without-using-split-function int versionComparison = localVersion.CompareTo(latestGitHubVersion); - if (versionComparison < 0) - { + if (versionComparison < 0) { if (MessageBox.Show( "Update available would you like to download?", "Update Available", MessageBoxButtons.YesNo, - MessageBoxIcon.Asterisk) == DialogResult.Yes) - { + MessageBoxIcon.Asterisk) == DialogResult.Yes) { System.Diagnostics.Process.Start("https://github.com/BytingBulldogs3539/Motion-Profile-Mapper/releases/latest"); } } - } - else if(!internet) - { + } else if (!internet) { MessageBox.Show("Update Check Failed", "Update Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private bool checkForInternet() - { - try - { + private bool checkForInternet() { + try { Ping myPing = new Ping(); String host = "google.com"; byte[] buffer = new byte[32]; int timeout = 1000; PingOptions pingOptions = new PingOptions(); PingReply reply = myPing.Send(host, timeout, buffer, pingOptions); - return (reply.Status == IPStatus.Success); - } - catch (Exception) - { + return ( reply.Status == IPStatus.Success ); + } catch (Exception) { return false; } } - private void mpButton_Click(object sender, EventArgs e) - { + private void mpButton_Click(object sender, EventArgs e) { mp.Show(); this.Hide(); } - private void constantsButton_Click(object sender, EventArgs e) - { + private void constantsButton_Click(object sender, EventArgs e) { constants.Show(); this.Hide(); } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MirrorPath.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MirrorPath.cs index b79d715..51ba8dc 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MirrorPath.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MirrorPath.cs @@ -9,16 +9,13 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Forms -{ - public partial class MirrorPath : Form - { +namespace MotionProfileMapper.Forms { + public partial class MirrorPath : Form { Profile selectedProfile; ProfilePath selectedPath; Action selectPath; double fieldHeight; - public MirrorPath(Profile selectedProfile, ProfilePath selectedPath, Action selectPath, double fieldHeight) - { + public MirrorPath(Profile selectedProfile, ProfilePath selectedPath, Action selectPath, double fieldHeight) { InitializeComponent(); this.selectedPath = selectedPath; this.selectedProfile = selectedProfile; @@ -26,20 +23,17 @@ public MirrorPath(Profile selectedProfile, ProfilePath selectedPath, Action this.fieldHeight = fieldHeight; } - private void cancelButton_Click(object sender, EventArgs e) - { + private void cancelButton_Click(object sender, EventArgs e) { this.Close(); } - private void mirrorSelectedButton_Click(object sender, EventArgs e) - { + private void mirrorSelectedButton_Click(object sender, EventArgs e) { this.selectedProfile.mirrorPath(this.selectedPath, this.fieldHeight); this.selectPath(-1); this.Close(); } - private void mirrorAllButton_Click(object sender, EventArgs e) - { + private void mirrorAllButton_Click(object sender, EventArgs e) { this.selectedProfile.mirrorAllPaths(fieldHeight); this.selectPath(-1); this.Close(); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.Designer.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.Designer.cs index 2c47be4..57310ee 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.Designer.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.Designer.cs @@ -1,7 +1,5 @@ -namespace MotionProfileMapper -{ - partial class MotionProfiler - { +namespace MotionProfileMapper { + partial class MotionProfiler { /// /// Required designer variable. /// @@ -11,10 +9,8 @@ partial class MotionProfiler /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { + protected override void Dispose(bool disposing) { + if (disposing && ( components != null )) { components.Dispose(); } base.Dispose(disposing); @@ -26,8 +22,7 @@ protected override void Dispose(bool disposing) /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// - private void InitializeComponent() - { + private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -116,21 +111,21 @@ private void InitializeComponent() this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); - ((System.ComponentModel.ISupportInitialize)(this.ControlPointTable)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.profileTable)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pathTable)).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.ControlPointTable ) ).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.profileTable ) ).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.pathTable ) ).BeginInit(); this.Data.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.kinematicsChart)).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.kinematicsChart ) ).BeginInit(); this.Field.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.splitContainer1 ) ).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.tableLayoutPanel5.SuspendLayout(); this.tableLayoutPanel6.SuspendLayout(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.mainField)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.trackBar)).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.mainField ) ).BeginInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.trackBar ) ).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); this.MoreData.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -141,10 +136,10 @@ private void InitializeComponent() // // infoLabel // - this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.infoLabel.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left ) + | System.Windows.Forms.AnchorStyles.Right ) ) ); this.infoLabel.BackColor = System.Drawing.SystemColors.ControlLight; - this.infoLabel.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.infoLabel.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.infoLabel.ForeColor = System.Drawing.Color.Black; this.infoLabel.Location = new System.Drawing.Point(2, 0); this.infoLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); @@ -166,8 +161,8 @@ private void InitializeComponent() this.ControlPointTable.AllowUserToResizeRows = false; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ButtonFace; this.ControlPointTable.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; - this.ControlPointTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); + this.ControlPointTable.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom ) + | System.Windows.Forms.AnchorStyles.Right ) ) ); this.ControlPointTable.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.ControlPointTable.BackgroundColor = System.Drawing.Color.White; this.ControlPointTable.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; @@ -175,7 +170,7 @@ private void InitializeComponent() this.ControlPointTable.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle2.BackColor = System.Drawing.Color.Silver; - dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; @@ -188,7 +183,7 @@ private void InitializeComponent() this.Direction}); dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; @@ -252,7 +247,7 @@ private void InitializeComponent() // label10 // this.label10.BackColor = System.Drawing.SystemColors.ControlLight; - this.label10.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.label10.ForeColor = System.Drawing.Color.Black; this.label10.Location = new System.Drawing.Point(10, 64); this.label10.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); @@ -270,15 +265,15 @@ private void InitializeComponent() this.profileTable.AllowUserToResizeRows = false; dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.ButtonFace; this.profileTable.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; - this.profileTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + this.profileTable.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom ) + | System.Windows.Forms.AnchorStyles.Left ) ) ); this.profileTable.BackgroundColor = System.Drawing.Color.White; this.profileTable.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.profileTable.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.profileTable.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle6.BackColor = System.Drawing.Color.Silver; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; @@ -290,7 +285,7 @@ private void InitializeComponent() this.dataGridViewTextBoxColumn3}); dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle7.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle7.SelectionForeColor = System.Drawing.Color.White; @@ -305,7 +300,7 @@ private void InitializeComponent() this.profileTable.Name = "profileTable"; this.profileTable.RightToLeft = System.Windows.Forms.RightToLeft.No; this.profileTable.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.profileTable.RowHeadersDefaultCellStyle = dataGridViewCellStyle8; this.profileTable.RowHeadersVisible = false; this.profileTable.RowHeadersWidth = 20; @@ -315,7 +310,6 @@ private void InitializeComponent() this.profileTable.TabIndex = 28; this.profileTable.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.profileTable_CellDoubleClick); this.profileTable.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.profileTable_CellEndEdit); - this.profileTable.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.profileTable_RowEnter); this.profileTable.SelectionChanged += new System.EventHandler(this.profileTable_SelectionChanged); // // dataGridViewTextBoxColumn2 @@ -346,7 +340,7 @@ private void InitializeComponent() this.pathTable.AllowUserToResizeRows = false; dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.ButtonFace; this.pathTable.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle9; - this.pathTable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pathTable.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.pathTable.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.pathTable.BackgroundColor = System.Drawing.Color.White; this.pathTable.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; @@ -354,7 +348,7 @@ private void InitializeComponent() this.pathTable.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle10.BackColor = System.Drawing.Color.Silver; - dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle10.SelectionForeColor = System.Drawing.Color.White; @@ -366,7 +360,7 @@ private void InitializeComponent() this.PathTime}); dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); dataGridViewCellStyle11.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.Teal; dataGridViewCellStyle11.SelectionForeColor = System.Drawing.Color.White; @@ -418,9 +412,9 @@ private void InitializeComponent() // // label4 // - this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label4.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.label4.BackColor = System.Drawing.SystemColors.ControlLight; - this.label4.Font = new System.Drawing.Font("Verdana", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Font = new System.Drawing.Font("Verdana", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.label4.ForeColor = System.Drawing.Color.Black; this.label4.Location = new System.Drawing.Point(784, 8); this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); @@ -432,9 +426,9 @@ private void InitializeComponent() // // label5 // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label5.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.label5.BackColor = System.Drawing.SystemColors.ControlLight; - this.label5.Font = new System.Drawing.Font("Verdana", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Font = new System.Drawing.Font("Verdana", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.label5.ForeColor = System.Drawing.Color.Black; this.label5.Location = new System.Drawing.Point(783, 275); this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); @@ -446,11 +440,11 @@ private void InitializeComponent() // // saveFileButton // - this.saveFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.saveFileButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.saveFileButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.saveFileButton.FlatAppearance.BorderSize = 0; this.saveFileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.saveFileButton.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveFileButton.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.saveFileButton.ForeColor = System.Drawing.Color.Black; this.saveFileButton.Location = new System.Drawing.Point(10, 548); this.saveFileButton.Margin = new System.Windows.Forms.Padding(1); @@ -464,11 +458,11 @@ private void InitializeComponent() // // saveAllButton // - this.saveAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.saveAllButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.saveAllButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.saveAllButton.FlatAppearance.BorderSize = 0; this.saveAllButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.saveAllButton.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveAllButton.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.saveAllButton.ForeColor = System.Drawing.Color.Black; this.saveAllButton.Location = new System.Drawing.Point(126, 548); this.saveAllButton.Margin = new System.Windows.Forms.Padding(1); @@ -524,7 +518,7 @@ private void InitializeComponent() // // uploadButton // - this.uploadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.uploadButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.uploadButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.uploadButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.uploadButton.ForeColor = System.Drawing.SystemColors.AppWorkspace; @@ -543,7 +537,7 @@ private void InitializeComponent() // // previewButton // - this.previewButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.previewButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.previewButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.previewButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.previewButton.ForeColor = System.Drawing.SystemColors.AppWorkspace; @@ -580,7 +574,7 @@ private void InitializeComponent() // // playButton // - this.playButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.playButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.playButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.playButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.playButton.ForeColor = System.Drawing.SystemColors.AppWorkspace; @@ -599,7 +593,7 @@ private void InitializeComponent() // // reverseButton // - this.reverseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.reverseButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.reverseButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.reverseButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.reverseButton.ForeColor = System.Drawing.Color.DarkGray; @@ -619,7 +613,7 @@ private void InitializeComponent() // // mirrorPathButton // - this.mirrorPathButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.mirrorPathButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.mirrorPathButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.mirrorPathButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.mirrorPathButton.ForeColor = System.Drawing.Color.DarkGray; @@ -638,7 +632,7 @@ private void InitializeComponent() // // deletePointButton // - this.deletePointButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.deletePointButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.deletePointButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.deletePointButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.deletePointButton.ForeColor = System.Drawing.Color.DarkGray; @@ -657,7 +651,7 @@ private void InitializeComponent() // // shiftPathButton // - this.shiftPathButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.shiftPathButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right ) ) ); this.shiftPathButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.shiftPathButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.shiftPathButton.ForeColor = System.Drawing.Color.DarkGray; @@ -676,7 +670,7 @@ private void InitializeComponent() // // duplicateProfileButton // - this.duplicateProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.duplicateProfileButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.duplicateProfileButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.duplicateProfileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.duplicateProfileButton.ForeColor = System.Drawing.Color.DarkGray; @@ -695,7 +689,7 @@ private void InitializeComponent() // // editPathButton // - this.editPathButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.editPathButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.editPathButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.editPathButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.editPathButton.ForeColor = System.Drawing.Color.DarkGray; @@ -733,7 +727,7 @@ private void InitializeComponent() // // editProfileButton // - this.editProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.editProfileButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.editProfileButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.editProfileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.editProfileButton.ForeColor = System.Drawing.Color.DarkGray; @@ -752,7 +746,7 @@ private void InitializeComponent() // // deleteProfileButton // - this.deleteProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.deleteProfileButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.deleteProfileButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.deleteProfileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.deleteProfileButton.ForeColor = System.Drawing.Color.DarkGray; @@ -771,7 +765,7 @@ private void InitializeComponent() // // newProfileButton // - this.newProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.newProfileButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.newProfileButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.newProfileButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.newProfileButton.ForeColor = System.Drawing.Color.DarkGray; @@ -790,7 +784,7 @@ private void InitializeComponent() // // deletePathButton // - this.deletePathButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.deletePathButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.deletePathButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.deletePathButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.deletePathButton.ForeColor = System.Drawing.Color.DarkGray; @@ -809,7 +803,7 @@ private void InitializeComponent() // // newPathButton // - this.newPathButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.newPathButton.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.newPathButton.BackColor = System.Drawing.SystemColors.ActiveBorder; this.newPathButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.newPathButton.ForeColor = System.Drawing.Color.DarkGray; @@ -828,7 +822,7 @@ private void InitializeComponent() // // pathOrderDown // - this.pathOrderDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pathOrderDown.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.pathOrderDown.BackColor = System.Drawing.SystemColors.ActiveBorder; this.pathOrderDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.pathOrderDown.Flip = FontAwesome.Sharp.FlipOrientation.Vertical; @@ -850,7 +844,7 @@ private void InitializeComponent() // // pathOrderUp // - this.pathOrderUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pathOrderUp.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right ) ) ); this.pathOrderUp.BackColor = System.Drawing.SystemColors.ActiveBorder; this.pathOrderUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.pathOrderUp.ForeColor = System.Drawing.Color.DarkGray; @@ -910,7 +904,7 @@ private void InitializeComponent() this.showPathsCheckbox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.showPathsCheckbox.Checked = true; this.showPathsCheckbox.CheckState = System.Windows.Forms.CheckState.Checked; - this.showPathsCheckbox.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.showPathsCheckbox.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.showPathsCheckbox.ForeColor = System.Drawing.Color.Black; this.showPathsCheckbox.Location = new System.Drawing.Point(29, 38); this.showPathsCheckbox.Margin = new System.Windows.Forms.Padding(0); @@ -929,7 +923,7 @@ private void InitializeComponent() this.GridCheckBox.BackColor = System.Drawing.SystemColors.ControlLight; this.GridCheckBox.Checked = true; this.GridCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.GridCheckBox.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.GridCheckBox.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.GridCheckBox.ForeColor = System.Drawing.Color.Black; this.GridCheckBox.Location = new System.Drawing.Point(42, 7); this.GridCheckBox.Margin = new System.Windows.Forms.Padding(0); @@ -1123,8 +1117,8 @@ private void InitializeComponent() // // trackBar // - this.trackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.trackBar.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) + | System.Windows.Forms.AnchorStyles.Right ) ) ); this.trackBar.Location = new System.Drawing.Point(2, 438); this.trackBar.Margin = new System.Windows.Forms.Padding(2); this.trackBar.Maximum = 1000; @@ -1158,9 +1152,9 @@ private void InitializeComponent() // // MoreData // - this.MoreData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.MoreData.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom ) + | System.Windows.Forms.AnchorStyles.Left ) + | System.Windows.Forms.AnchorStyles.Right ) ) ); this.MoreData.Controls.Add(this.Field); this.MoreData.Controls.Add(this.Data); this.MoreData.Location = new System.Drawing.Point(245, 0); @@ -1178,7 +1172,7 @@ private void InitializeComponent() // // timeSinceUpload // - this.timeSinceUpload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.timeSinceUpload.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.timeSinceUpload.AutoSize = true; this.timeSinceUpload.ForeColor = System.Drawing.Color.Black; this.timeSinceUpload.Location = new System.Drawing.Point(11, 574); @@ -1220,7 +1214,7 @@ private void InitializeComponent() // undoToolStripMenuItem // this.undoToolStripMenuItem.Name = "undoToolStripMenuItem"; - this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); + this.undoToolStripMenuItem.ShortcutKeys = ( (System.Windows.Forms.Keys) ( ( System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z ) ) ); this.undoToolStripMenuItem.Size = new System.Drawing.Size(144, 22); this.undoToolStripMenuItem.Text = "Undo"; this.undoToolStripMenuItem.Click += new System.EventHandler(this.undoToolStripMenuItem_Click); @@ -1228,7 +1222,7 @@ private void InitializeComponent() // redoToolStripMenuItem // this.redoToolStripMenuItem.Name = "redoToolStripMenuItem"; - this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); + this.redoToolStripMenuItem.ShortcutKeys = ( (System.Windows.Forms.Keys) ( ( System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y ) ) ); this.redoToolStripMenuItem.Size = new System.Drawing.Size(144, 22); this.redoToolStripMenuItem.Text = "Redo"; this.redoToolStripMenuItem.Click += new System.EventHandler(this.redoToolStripMenuItem_Click); @@ -1242,7 +1236,7 @@ private void InitializeComponent() // // currentTime // - this.currentTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.currentTime.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left ) ) ); this.currentTime.AutoSize = true; this.currentTime.Location = new System.Drawing.Point(11, 593); this.currentTime.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); @@ -1334,9 +1328,9 @@ private void InitializeComponent() this.Controls.Add(this.ControlPointTable); this.Controls.Add(this.MoreData); this.Controls.Add(this.menuStrip1); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) )); this.ForeColor = System.Drawing.Color.Black; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Icon = ( (System.Drawing.Icon) ( resources.GetObject("$this.Icon") ) ); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; this.Margin = new System.Windows.Forms.Padding(2); @@ -1349,22 +1343,22 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.MainForm_Load); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MainForm_KeyPress); this.Resize += new System.EventHandler(this.MotionProfiler_Resize); - ((System.ComponentModel.ISupportInitialize)(this.ControlPointTable)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.profileTable)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pathTable)).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.ControlPointTable ) ).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.profileTable ) ).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.pathTable ) ).EndInit(); this.Data.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.kinematicsChart)).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.kinematicsChart ) ).EndInit(); this.Field.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.splitContainer1 ) ).EndInit(); this.splitContainer1.ResumeLayout(false); this.tableLayoutPanel5.ResumeLayout(false); this.tableLayoutPanel6.ResumeLayout(false); this.tableLayoutPanel6.PerformLayout(); this.panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.mainField)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.trackBar)).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.mainField ) ).EndInit(); + ( (System.ComponentModel.ISupportInitialize) ( this.trackBar ) ).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); this.MoreData.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs index 75d1ff7..cd3efef 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/MotionProfiler.cs @@ -527,14 +527,9 @@ private void SaveAllProfiles(object sender, EventArgs e) { setStatus("Saving profiles to file system...", false); foreach (Profile profile in profiles) { string mpPath = System.IO.Path.Combine(mpBasePath, profile.Name.Replace(' ', '_') + ".mp"); - //string javaPath = System.IO.Path.Combine(mpBasePath, profile.Name.Replace(' ', '_') + ".java"); using (var writer = new StreamWriter(mpPath)) { writer.Write(profile.toJSON().ToString()); } - //using (var writer = new StreamWriter(javaPath)) - //{ - // writer.Write(profile.toJava()); - //} } setStatus("Profiles saved to file system", false); Cursor = Cursors.Default; @@ -552,7 +547,6 @@ private void SaveSelectedProfile(object sender, EventArgs e) { browser.Filter = "Motion Profile|*.mp;"; browser.Title = "Save motion profile file"; - String mpBasePath = ""; if (!Directory.Exists(Properties.Settings.Default.javaSavePath) || !Directory.Exists(Properties.Settings.Default.iniSavePath)) { @@ -699,12 +693,6 @@ private void selectProfile(int index = -1) { UpdateField(); } - private void profileTable_RowEnter(object sender, DataGridViewCellEventArgs e) { - //Console.WriteLine("row Enter"); - - //selectProfile(e.RowIndex); - } - private void newProfileButton_Click(object sender, EventArgs e) { skipPathSelectionChange = true; saveUndoState("New Profile", true, null, false); @@ -817,7 +805,10 @@ private void setStatus(string message, bool error) { infoLabel.Text = message; infoLabel.ForeColor = error ? Color.Red : Color.Black; } - + /// + /// Used to determine if the user has a profile selected + /// + /// True if there is no profile selected private bool noSelectedProfile() { if (profiles.IndexOf(selectedProfile) == -1) { setStatus("Create or select a profile", true); @@ -826,6 +817,10 @@ private bool noSelectedProfile() { return false; } + /// + /// Used to determine if the user has a path selected from a profile. + /// + /// True if there is no profile or path selected private bool noSelectedPath() { if (noSelectedProfile()) return true; if (selectedProfile.Paths.IndexOf(selectedPath) == -1) { @@ -835,6 +830,10 @@ private bool noSelectedPath() { return false; } + /// + /// Used to tell if there are actually any points in a selected path. + /// + /// True if there are no points in the selected path private bool noPointsInPath() { if (noSelectedProfile() || noSelectedPath()) return true; if (selectedPath.isEmpty()) { @@ -844,19 +843,29 @@ private bool noPointsInPath() { return false; } + private void pathTable_RowEnter(object sender, DataGridViewCellEventArgs e) { if (skipPathSelectionChange) return; selectPath(e.RowIndex); } + /// + /// Select a path from the currently selected profile. + /// + /// Index to select -1 reselects the current path private void selectPath(int index = -1) { selectPath(true, index); } bool skipPathSelectionChange = false; + + /// + /// Select a path from the currently selected profile. + /// + /// If true the trackbar will not be reset when the path is selected + /// Index to select -1 reselects the current path private void selectPath(bool doResetTrackBar, int index = -1) { - // -1 reselects current path i think ControlPointTable.Rows.Clear(); if (placingPoint != null) placingPoint = null; @@ -869,8 +878,6 @@ private void selectPath(bool doResetTrackBar, int index = -1) { skipUpdate = false; } - - if (!noSelectedPath()) { foreach (ControlPoint point in selectedPath.ControlPoints) { ControlPointTable.Rows.Add(Math.Round(point.X, 3), Math.Round(point.Y, 3), point.Rotation); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PathSettings.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PathSettings.cs index 83654ae..d8c99f9 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PathSettings.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PathSettings.cs @@ -9,14 +9,11 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Forms -{ - public partial class PathSettings : Form - { +namespace MotionProfileMapper.Forms { + public partial class PathSettings : Form { ProfilePath path; DataGridViewCell pathTableCell; - public PathSettings(ProfilePath path, DataGridViewCell pathTable) - { + public PathSettings(ProfilePath path, DataGridViewCell pathTable) { InitializeComponent(); this.pathMaxVelInput.Text = path.MaxVel.ToString(); this.pathMaxAccInput.Text = path.MaxAcc.ToString(); @@ -32,8 +29,7 @@ public PathSettings(ProfilePath path, DataGridViewCell pathTable) ActiveControl = pathNameInput; } - private void save_Click(object sender, EventArgs e) - { + private void save_Click(object sender, EventArgs e) { double maxvel; double maxacc; double maxcen; @@ -45,37 +41,32 @@ private void save_Click(object sender, EventArgs e) bool d = double.TryParse(pathOutVelInput.Text, out outvel); bool f = double.TryParse(pathInVelInput.Text, out invel); - if (!a || !b || !c || !d || !f) - { + if (!a || !b || !c || !d || !f) { MessageBox.Show("Incorrect Data Types", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.path.updateAll(this.pathNameInput.Text, this.snapToPrevBox.Checked, maxvel, invel, outvel, maxacc, maxcen); - + //this.pathTableCell.Value = this.path.Name; this.Close(); } - private void cancel_Click(object sender, EventArgs e) - { + private void cancel_Click(object sender, EventArgs e) { this.Close(); } - private void pathNameInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) save_Click(null, null); + private void pathNameInput_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char) Keys.Enter) save_Click(null, null); } - private void pathMaxVelInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) save_Click(null, null); + private void pathMaxVelInput_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char) Keys.Enter) save_Click(null, null); } - private void pathMaxAccInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) save_Click(null, null); + private void pathMaxAccInput_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char) Keys.Enter) save_Click(null, null); } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.Designer.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.Designer.cs deleted file mode 100644 index fbf5986..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.Designer.cs +++ /dev/null @@ -1,176 +0,0 @@ - -namespace MotionProfileMapper.Forms -{ - partial class PoseVisualizer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PoseVisualizer)); - this.loadFromRIOButton = new System.Windows.Forms.Button(); - this.rioConectionButton = new FontAwesome.Sharp.IconButton(); - this.trackBar1 = new System.Windows.Forms.TrackBar(); - this.mainField = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.GridCheckBox = new System.Windows.Forms.CheckBox(); - ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.mainField)).BeginInit(); - this.SuspendLayout(); - // - // loadFromRIOButton - // - this.loadFromRIOButton.BackColor = System.Drawing.SystemColors.ActiveBorder; - this.loadFromRIOButton.Cursor = System.Windows.Forms.Cursors.Hand; - this.loadFromRIOButton.FlatAppearance.BorderSize = 0; - this.loadFromRIOButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.loadFromRIOButton.Font = new System.Drawing.Font("Verdana", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.loadFromRIOButton.ForeColor = System.Drawing.Color.Teal; - this.loadFromRIOButton.Location = new System.Drawing.Point(12, 610); - this.loadFromRIOButton.Name = "loadFromRIOButton"; - this.loadFromRIOButton.Size = new System.Drawing.Size(253, 50); - this.loadFromRIOButton.TabIndex = 58; - this.loadFromRIOButton.Text = "Load from RIO"; - this.loadFromRIOButton.UseVisualStyleBackColor = false; - this.loadFromRIOButton.Click += new System.EventHandler(this.loadFromRIOButton_Click); - // - // rioConectionButton - // - this.rioConectionButton.BackColor = System.Drawing.SystemColors.ActiveBorder; - this.rioConectionButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.rioConectionButton.Cursor = System.Windows.Forms.Cursors.Hand; - this.rioConectionButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.rioConectionButton.ForeColor = System.Drawing.SystemColors.AppWorkspace; - this.rioConectionButton.IconChar = FontAwesome.Sharp.IconChar.Cog; - this.rioConectionButton.IconColor = System.Drawing.Color.Teal; - this.rioConectionButton.IconFont = FontAwesome.Sharp.IconFont.Auto; - this.rioConectionButton.IconSize = 25; - this.rioConectionButton.Location = new System.Drawing.Point(268, 610); - this.rioConectionButton.Margin = new System.Windows.Forms.Padding(0); - this.rioConectionButton.Name = "rioConectionButton"; - this.rioConectionButton.Size = new System.Drawing.Size(54, 50); - this.rioConectionButton.TabIndex = 59; - this.rioConectionButton.UseVisualStyleBackColor = false; - // - // trackBar1 - // - this.trackBar1.Location = new System.Drawing.Point(12, 527); - this.trackBar1.Name = "trackBar1"; - this.trackBar1.Size = new System.Drawing.Size(1044, 45); - this.trackBar1.TabIndex = 63; - // - // mainField - // - this.mainField.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.mainField.BackColor = System.Drawing.SystemColors.ControlLight; - chartArea1.BackImageWrapMode = System.Windows.Forms.DataVisualization.Charting.ChartImageWrapMode.Scaled; - chartArea1.Name = "field"; - this.mainField.ChartAreas.Add(chartArea1); - this.mainField.Cursor = System.Windows.Forms.Cursors.Cross; - this.mainField.Location = new System.Drawing.Point(2, 2); - this.mainField.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); - this.mainField.Name = "mainField"; - series1.ChartArea = "field"; - series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; - series1.MarkerBorderColor = System.Drawing.Color.Transparent; - series1.MarkerColor = System.Drawing.Color.Transparent; - series1.Name = "background"; - series2.ChartArea = "field"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series2.Color = System.Drawing.Color.LightGray; - series2.MarkerSize = 2; - series2.Name = "right"; - series3.ChartArea = "field"; - series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series3.Color = System.Drawing.Color.LightGray; - series3.MarkerSize = 2; - series3.Name = "left"; - series4.ChartArea = "field"; - series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series4.Color = System.Drawing.Color.Aqua; - series4.MarkerSize = 4; - series4.Name = "path"; - this.mainField.Series.Add(series1); - this.mainField.Series.Add(series2); - this.mainField.Series.Add(series3); - this.mainField.Series.Add(series4); - this.mainField.Size = new System.Drawing.Size(1042, 519); - this.mainField.TabIndex = 64; - this.mainField.Text = "chart2"; - // - // GridCheckBox - // - this.GridCheckBox.Anchor = System.Windows.Forms.AnchorStyles.None; - this.GridCheckBox.AutoSize = true; - this.GridCheckBox.BackColor = System.Drawing.SystemColors.ControlLight; - this.GridCheckBox.Cursor = System.Windows.Forms.Cursors.Hand; - this.GridCheckBox.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.GridCheckBox.ForeColor = System.Drawing.Color.Black; - this.GridCheckBox.Location = new System.Drawing.Point(856, 629); - this.GridCheckBox.Margin = new System.Windows.Forms.Padding(1); - this.GridCheckBox.Name = "GridCheckBox"; - this.GridCheckBox.Size = new System.Drawing.Size(83, 17); - this.GridCheckBox.TabIndex = 65; - this.GridCheckBox.Text = "Show grid"; - this.GridCheckBox.UseVisualStyleBackColor = false; - this.GridCheckBox.CheckedChanged += new System.EventHandler(this.GridCheckBox_CheckedChanged); - // - // PoseVisualizer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.SystemColors.ControlLight; - this.ClientSize = new System.Drawing.Size(1068, 674); - this.Controls.Add(this.GridCheckBox); - this.Controls.Add(this.mainField); - this.Controls.Add(this.trackBar1); - this.Controls.Add(this.rioConectionButton); - this.Controls.Add(this.loadFromRIOButton); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "PoseVisualizer"; - this.Text = "Pose Visualizer"; - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.PoseVisualizer_FormClosed); - ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.mainField)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private FontAwesome.Sharp.IconButton rioConectionButton; - private System.Windows.Forms.Button loadFromRIOButton; - private System.Windows.Forms.TrackBar trackBar1; - private System.Windows.Forms.DataVisualization.Charting.Chart mainField; - private System.Windows.Forms.CheckBox GridCheckBox; - } -} \ No newline at end of file diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.cs deleted file mode 100644 index c1077bf..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Drawing.Imaging; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Windows.Forms.DataVisualization.Charting; - -namespace MotionProfileMapper.Forms -{ - public partial class PoseVisualizer : Form - { - Action closeMain; - private double fieldWidth = 15.816; - private double fieldHeight = 8.016; - - public PoseVisualizer(Action closeMain) - { - this.closeMain = closeMain; - InitializeComponent(); - SetupMainField(); - } - - private void SetupMainField() - { - mainField.ChartAreas["field"].Axes[0].Minimum = 0; - mainField.ChartAreas["field"].Axes[0].Maximum = fieldWidth; - mainField.ChartAreas["field"].Axes[0].Interval = 1; - mainField.ChartAreas["field"].Axes[0].MajorGrid.LineColor = Color.Gray; - - mainField.ChartAreas["field"].Axes[1].Minimum = 0; - mainField.ChartAreas["field"].Axes[1].Maximum = fieldHeight; - mainField.ChartAreas["field"].Axes[1].Interval = 1; - mainField.ChartAreas["field"].Axes[1].MajorGrid.LineColor = Color.Gray; - - mainField.Series["background"].Points.AddXY(0, 0); - mainField.Series["background"].Points.AddXY(fieldWidth, fieldHeight); - mainField.ChartAreas[0].AxisX.MajorGrid.Enabled = false; - mainField.ChartAreas[0].AxisY.MajorGrid.Enabled = false; - - mainField.ChartAreas["field"].AxisY2.Enabled = AxisEnabled.True; - mainField.ChartAreas["field"].AxisY2.LabelStyle.Enabled = false; - mainField.ChartAreas["field"].AxisY2.MajorGrid.Enabled = false; - mainField.ChartAreas["field"].AxisY2.MajorTickMark.Enabled = false; - mainField.ChartAreas["field"].AxisX2.Enabled = AxisEnabled.True; - mainField.ChartAreas["field"].AxisX2.LabelStyle.Enabled = false; - mainField.ChartAreas["field"].AxisX2.MajorGrid.Enabled = false; - mainField.ChartAreas["field"].AxisX2.MajorTickMark.Enabled = false; - - mainField.Images.Add(new NamedImage("2023-full-field", setOpacity(MotionProfileMapper.Properties.Resources._2023_full_field, 0.5f))); - mainField.ChartAreas["field"].BackImageWrapMode = ChartImageWrapMode.Scaled; - mainField.ChartAreas["field"].BackImage = "2023-full-field"; - mainField.ForeColor = Color.Black; - } - - private Bitmap setOpacity(Image image, float opacity) - { - Bitmap opaque = new Bitmap(image.Width, image.Height); - using (Graphics g = Graphics.FromImage(opaque)) - { - ColorMatrix matrix = new ColorMatrix(); - matrix.Matrix33 = opacity; - ImageAttributes attributes = new ImageAttributes(); - attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); - g.DrawImage( - image, - new Rectangle(0, 0, opaque.Width, opaque.Height), - 0, 0, - image.Width, image.Height, - GraphicsUnit.Pixel, attributes - ); - } - return opaque; - } - - private void loadFromRIOButton_Click(object sender, EventArgs e) - { - - } - - private void PoseVisualizer_FormClosed(object sender, FormClosedEventArgs e) - { - this.closeMain(); - } - - private void GridCheckBox_CheckedChanged(object sender, EventArgs e) - { - if (GridCheckBox.CheckState == CheckState.Unchecked) - { - mainField.ChartAreas[0].AxisX.MajorGrid.Enabled = false; - mainField.ChartAreas[0].AxisY.MajorGrid.Enabled = false; - } - else - { - mainField.ChartAreas[0].AxisX.MajorGrid.Enabled = true; - mainField.ChartAreas[0].AxisY.MajorGrid.Enabled = true; - } - } - } -} diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.resx b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.resx deleted file mode 100644 index db424a3..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/PoseVisualizer.resx +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAAAAAAAAAAAAAAAAAAAA - AAAs2Ib/LNqH/y3cif8t3In/LdyJ/y3cif8t3Yn/K9SE/yGiZP8fll3/H5dd/x+XXv8gnWH/Elk3/wYe - Ev8GHxP/H5de/y3cif8TXDn/DD0m/yjGe/8s2of/K9OD/xJZN/8MPCX/K9SD/y3dif8t3In/LdyJ/y3c - if8s2of/LNiG/yzah/8ltHD/Gn9P/xqAT/8agE//GoBP/xqBUP8XcEX/CS0c/xNdOv8UYz3/Elc2/wQS - C/8IKRn/IJtg/xZtQ/8JLhz/GXpM/ww8Jf8fmmD/LNqH/yzYhv8s2Yf/JbZx/ws4I/8ZeUv/GoBP/xqA - T/8agE//Gn9P/yW0cP8s2of/LdyJ/xp/T/8AAAD/AAAA/wAAAP8AAAD/AAAA/wQSC/8bh1T/LNaF/yza - h/8q0IH/FWY//xNdOv8r1YT/G4NR/xl5S/8afk7/DDwl/yGgZP8t24j/LNiG/yzah/8nvnb/BhwR/wAB - AP8AAAD/AAAA/wAAAP8AAAD/Gn9P/y3cif8t3In/GoBP/wAAAP8AAAD/AAAA/wAAAP8BBAL/GoBP/yzW - hf8s2Yb/LNiG/y3ciP8hoWT/FGE8/yzWhf8ltHD/K9OD/y3eiv8UZD7/IaBk/y3ciP8s2Ib/LNqH/ya8 - dP8ORSv/FGM9/wIKBv8AAAD/AAAA/wAAAP8agE//LdyJ/y3cif8agE//AAAA/wAAAP8SEhL/JSUl/wcl - F/8ks2//LduI/yzYhv8s2Ib/LduI/yCfYv8UYTz/LNmH/yzah/8t2oj/JsN4/wpEKP8YfE3/K9SE/yzY - hv8s2of/J711/xFRM/8pyHz/EFAy/wAAAP8AAAD/AAAA/xqAT/8t3In/LdyJ/xqAT/8AAAD/AAAA/yUl - Jf9NTE3/GHpM/yzah/8s2Ib/LNiG/yzYhv8t24j/IJ5i/xRgPP8s2Yb/LNmH/ybCeP89fV7/Z2dn/yA4 - Lf8lvnX/LNqH/yzWhf8bg1H/DkUr/yOta/8KNSD/AAAA/wAAAP8AAAD/GoBP/y3cif8t3In/GoBP/wAA - AP8AAAD/AAAA/wACAf8bg1H/LdyI/yzYhv8s2Ib/LNiG/yzZh/8nwHf/Iqdo/yzYhv8s2of/Hptg/ywx - L/+8vbz/m6Of/yeCVv8q1IP/KtCB/w5EKv8TYDv/CjUh/05NTf8lJSX/AAAA/wAAAP8agE//LdyJ/y3c - if8agE//AAAA/wAAAP8AAAD/DkMp/yjDef8s2Yf/LNiG/yzYhv8s2Ib/LNiG/yzZh/8s2of/LNmH/ynH - fP8MOyX/AAcD/zmIYv9Mimz/KKVq/yvXhf8nwnj/Czci/wcgFP8AAAD/JSUl/xISEv8AAAD/AAAA/xqA - T/8t3In/LdyJ/xp/T/8oJyj/Ojo6/wcDBf8RWDb/LduI/yzYhv8s2Ib/LNiG/yzYhv8s2Ib/LNiG/yzY - hv8s14b/H5pg/wUaEP8WbEP/KM1+/yS/df8ktHD/LNmG/xVpQf8BAwL/AAAA/wAAAP8AAAD/AAAA/wAA - AP8AAAD/GoBP/y3cif8t3In/GX9O/1hXWP/BwMH/IzMs/xqIVP8s2Yf/LNiG/yzYhv8s2Ib/LNiG/yzY - hv8s2Ib/LNqH/yrQgf8ORSv/EVIz/yCfYv8t24j/J711/xFWNf8jq2r/CjMg/wAAAP8AAAD/AAAA/wAA - AP8AAAD/AAAA/wAAAP8agE//LdyJ/y3cif8agE//BAMD/0I/QP8ZRDD/KtCB/yzYhv8s2Ib/LNiG/yzY - hv8s2Ib/LNqH/ya4cv8TXTr/IJtg/w5DKv8SWDf/IaRm/yrQgf8af0//HpJb/xh3Sv8AAAD/AAAA/wAA - AP8AAAD/AAAA/wAAAP8AAAD/AAAA/xqAT/8t3In/Ld2J/xqCUP8AAAD/AAAA/wo1If8q0IH/LNiG/yzY - hv8s2Ib/LNiG/yzYhv8t24j/IaFk/wEDAv8YdEj/EEwv/yCbYP8r0YL/F3FG/xyKVv8gnmL/CCUX/wAA - AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/GoBP/y3cif8qz4D/EmE7/wAAAP8AAAD/Czci/yvS - gv8s2Ib/LNiG/yzYhv8s2Ib/LNiG/y3biP8hoWT/AQUD/xh2Sf8QTTD/HZBZ/xZrQ/8DDwn/FmtC/wgm - GP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8agE//LdyJ/xFbOP8tNTH/ZmZm/xoY - Gf8FHBH/IJ9j/yzZh/8s2Ib/LNiG/yzYhv8s2Ib/LNqH/ya6c/8LOCP/GHdK/ww7JP8BBAL/AQQC/wAA - AP8BBQP/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/xqAUP8t3Yn/JSMk/7Kx - sv/v7+//Pj8+/wAAAP8RVDT/LNeF/yzZhv8s2Ib/LNiG/yzYhv8s2Ib/LdyJ/xp/T/8KLx3/BRgP/wAA - AP8AAAD/AAAA/wAAAP8BBwT/AQcE/xBOMP8agVD/GoFQ/xBOMP8BBwT/AQYE/wgoGf8PSS3/DD0m/yW2 - cf8ZLiT/Qk9J/z08PP8UJR3/FWxD/wkrG/8bhVP/K9SD/yzZh/8s2of/LNiG/yzYhv8t24j/HIpW/wII - Bf8AAAD/AAAA/wAAAP8DDQj/CSsb/x6SWv8ho2X/KMR6/y3dif8t3Yn/KMR6/yGkZv8hpGb/JLJu/yjC - ef8PSS7/H5dd/ybBd/8TbUL/AAAA/wUbEP8jrmz/FWlB/wgoGf8iqGj/Ks1//ya6dP8s2Ib/LNiG/yzY - hv8qzoD/EE4w/wAAAP8AAAD/BBUN/xuGU/8oxHr/LNiG/y3biP8s2Yf/LNiG/yzZh/8t3Yn/Jr11/yOr - av8s14X/Ld6K/xRkPv8fl13/Ld6K/xqBUP8AAAD/Bh0S/xyIVP8VZT//HY5Y/ya5c/8homX/FWU//yzZ - h/8s2Ib/LNiG/y3biP8SWjj/AAAA/wAAAP8SVjX/LNiG/yzah/8s2Ib/LNiG/yzYhv8s2of/KMJ5/xuD - Uf8LNyL/BBQM/xdwRv8agE//DD0m/x+YXv8r1IP/F3lK/wQCA/8FDwr/CjQg/xNcOf8s2of/LduI/yGh - ZP8UYjz/LNaF/yzah/8muHL/HpNb/xFUNP8AAAD/AAAA/wgnGP8hpGb/K9OD/yzZhv8s2Yf/LNiG/yvV - hP8gnGH/AQYE/w5FK/8KLx3/FWhA/w5FK/8QTjD/J8F4/xVBLP8nQDT/eHh4/zIxMv8AAAD/FWlB/yzZ - h/8s2Yf/Ks1//xh1Sf8bhVL/LNeF/yrMfv8agFD/CjAd/wUZEP8GGxH/D0gt/xFWNf8ORSv/I61r/ynK - ff8r0oL/E106/wclF/8AAAD/FGhA/w5KLf8LNCD/ByEU/xqBUP8t3Yn/LCYp/5mWl//U1NT/Q0FC/wMd - EP8hpGb/LNmG/yzYhv8t3Ij/HpZd/wglF/8bg1L/LNiG/yvSgv8nwXj/Jrp0/xyOV/8OVzX/AAgE/wAA - AP8EEgv/FWdA/yvUg/8SVjb/Aw0I/wo0IP8vVEL/LJJh/wQWDf8AAAD/GoBP/y3cif8WXjv/FT8r/1dX - V/8oKCj/AAAA/xNfO/8s2of/LNiG/yzYhv8r1YT/HIlV/xRgO/8Zekz/Gn9P/xqAUP8YfEz/K2pM/2hu - a/8sKyv/AAAA/wQSC/8ciVX/LNaF/xyKVv8Ze0z/Iqdn/1mDb/81dFb/AQ8J/wAAAP8agE//LdyJ/y3d - if8agE//AAAA/wAAAP8AAAD/ByQW/yKlZv8t24j/LNiG/yzYhv8s2of/Ks6A/xyJVf8afk7/Czci/xJn - Pv9f2qD/t8C8/y45NP8NSSz/D0su/yvRgv8py37/DUIp/xh1Sf8Ze0z/DUAo/wYfE/8AAAD/AAAA/xqA - T/8t3In/LdyJ/xqAT/8AAAD/AAAA/wAAAP8AAAD/F29F/yzXhf8s2Yf/LNiG/yzYhv8s2Ib/LduI/y3c - if8UYz3/IJ9i/zCqcP8xb1H/GYFP/xVpQf8ipWf/LNeG/xyLVv8cilb/JbVw/xp/T/8GHxP/Aw8J/wAA - AP8AAAD/GoBP/y3cif8t3In/GoBP/wAAAP8AAAD/AAAA/wAAAP8CEgr/HIhU/yzWhf8s2Yb/LNiG/yzY - hv8s2Ib/LNmG/xRgO/8dj1n/FnFG/xRrQf8SVjb/IqVm/yzYhv8s2Ib/Kcl8/yrPgP8kr23/E187/wAA - AP8AAAD/AAAA/wAAAP8agE//LdyJ/y3cif8agE//AAAA/wAAAP8aGhr/ZmZm/ysqK/8CEQr/G4dU/yzW - hf8s2Ib/LNiG/yzYhv8s2Yb/HY5Y/xp+Tv8iqWn/HpNb/yrPgf8s14X/LNmG/yzZh/8s2Ib/HIhU/wQV - Df8BBAL/AAAA/wAAAP8AAAD/AAAA/xqAT/8t3In/LdyJ/xqAT/8AAAD/Dw8P/5aWlv/29vb/ZmZm/wAA - AP8LNSH/K9GC/yzZh/8s2Ib/LNiG/yzYhv8r1YT/IKBj/yrMf/8s2Yf/LNqH/yzZhv8r04P/IJ9i/xFU - NP8EFQ3/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/GoBP/y3cif8t3In/GoBP/wAAAP8ICAj/Ozs7/0BB - QP8aGBn/AAAA/ws1If8px3v/Ks6A/yzZh/8t24j/LduI/yzZh/8t24j/LduI/y3biP8py37/I61r/w5E - Kv8IJhj/AQUD/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8agE//LdyJ/y3cif8agE//AAAA/wAA - AP8AAAD/AAAA/wUcEf8LNSH/EVIz/xRjPf8cilb/LNeF/yKpaf8hoWT/KMV6/yzWhf8iqWn/IaNl/xBQ - Mf8FFw7/CS0c/xZtRP8Xb0X/Ci8d/wEHBP8AAAD/AAAA/wAAAP8AAAD/AAAA/xqAT/8t3In/LdyJ/xp/ - T/8AAAD/AAAA/wAAAP8HJBb/IaBj/yvUg/8ltnH/DDsl/xl8Tf8ci1b/BBQM/wEFA/8QTjD/F3JG/wQV - Df8BBgP/CzYi/xVoQP8ownj/LNaF/yvTg/8af0//AgwH/wAAAP8AAAD/AAAA/wAAAP8AAAD/Gn9P/y3c - if8s2of/JbRw/xqAUP8Xb0X/CSsb/x+WXf8s1oX/LNmG/y3cif8af0//F3BF/w5GK/8WbUP/GoBQ/xp/ - T/8af0//GoFQ/xBOMP8MPCX/JbVx/yWzb/8UYTz/E146/wktHP8XcEb/GoFQ/xqAT/8agE//GoBP/xp/ - T/8ltHD/LNqH/yzYhv8s2of/Ld6K/yfBeP8JKxv/DDsk/x+YX/8t24j/LdyI/xp/T/8GHxP/CSsb/yfB - eP8t3or/LdyJ/y3cif8t3Yn/KMJ4/w0/J/8JKxv/CSsb/w0+Jv8fl17/IaJk/yvUhP8t3Yn/LdyJ/y3c - if8t3In/LdyJ/yzah/8s2Ib/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - \ No newline at end of file diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Preview.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Preview.cs index 2284c3b..76e6c6a 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Preview.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Preview.cs @@ -8,12 +8,9 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Forms -{ - public partial class Preview : Form - { - public Preview(string displayText) - { +namespace MotionProfileMapper.Forms { + public partial class Preview : Form { + public Preview(string displayText) { InitializeComponent(); this.previewBox.Text = displayText; } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs index fcc03e1..c53ab27 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/Settings.cs @@ -9,12 +9,9 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper -{ - public partial class Settings : Form - { - public Settings() - { +namespace MotionProfileMapper { + public partial class Settings : Form { + public Settings() { InitializeComponent(); this.ipaddress.Text = Properties.Settings.Default.IpAddress; this.username.Text = Properties.Settings.Default.Username; @@ -37,10 +34,8 @@ public Settings() this.snapPathsCheckbox.Checked = Properties.Settings.Default.SnapNewPaths; } - private void save_Click(object sender, EventArgs e) - { - if (!ValidateIPv4(this.ipaddress.Text)) - { + private void save_Click(object sender, EventArgs e) { + if (!ValidateIPv4(this.ipaddress.Text)) { MessageBox.Show("This ip address is invalid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -48,8 +43,8 @@ private void save_Click(object sender, EventArgs e) Properties.Settings.Default.IpAddress = this.ipaddress.Text; Properties.Settings.Default.Username = this.username.Text; Properties.Settings.Default.Password = this.password.Text; - Properties.Settings.Default.RioLocation = this.riopath.Text + (this.riopath.Text.Last().ToString() == "/"? "" : "/"); - Properties.Settings.Default.INILocation = this.iniPath.Text + (this.iniPath.Text.Last().ToString() == "/" ? "" : "/"); + Properties.Settings.Default.RioLocation = this.riopath.Text + ( this.riopath.Text.Last().ToString() == "/" ? "" : "/" ); + Properties.Settings.Default.INILocation = this.iniPath.Text + ( this.iniPath.Text.Last().ToString() == "/" ? "" : "/" ); Properties.Settings.Default.defaultAllianceIsRed = this.checkBox1.Checked; Properties.Settings.Default.autoCheckForUpdates = this.checkBox2.Checked; @@ -57,69 +52,48 @@ private void save_Click(object sender, EventArgs e) Properties.Settings.Default.javaSavePath = javaSavePath.Text; Properties.Settings.Default.mpSavePath = mpSavePath.Text; - try - { + try { Properties.Settings.Default.MaxVel = double.Parse(defMaxVelInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max velocity must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.FrameLength = double.Parse(this.frameLengthInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max velocity must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.FrameWidth = double.Parse(this.frameWidthInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max velocity must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.MaxAcc = double.Parse(defMaxAccInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max acceleration must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.MaxCen = double.Parse(defMaxCenAccInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max centripetal acceleration must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.MaxRotVel = double.Parse(defMaxRotVelInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max rotational velocity must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - try - { + try { Properties.Settings.Default.MaxRotAcc = double.Parse(defMaxRotAccInput.Text); - } - catch (Exception) - { + } catch (Exception) { MessageBox.Show("Max rotational acceleration must be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -134,17 +108,14 @@ private void save_Click(object sender, EventArgs e) /// /// The ip string value. /// a boolean that tells you if the ip is in ipv4 format. - public bool ValidateIPv4(string ipString) - { + public bool ValidateIPv4(string ipString) { // if the text contains a whitespace/space or a null value then it is clearly not a ip address. - if (String.IsNullOrWhiteSpace(ipString)) - { + if (String.IsNullOrWhiteSpace(ipString)) { return false; } //Split the ip address into different parts string[] splitValues = ipString.Split('.'); - if (splitValues.Length != 4) - { + if (splitValues.Length != 4) { return false; } @@ -153,13 +124,11 @@ public bool ValidateIPv4(string ipString) return splitValues.All(r => byte.TryParse(r, out tempForParsing)); } - private void cancel_Click(object sender, EventArgs e) - { + private void cancel_Click(object sender, EventArgs e) { this.Close(); } - private void iconButton1_Click(object sender, EventArgs e) - { + private void iconButton1_Click(object sender, EventArgs e) { SaveFileDialog browser = new SaveFileDialog(); browser.RestoreDirectory = true; browser.Filter = "Directory | directory"; @@ -172,8 +141,7 @@ private void iconButton1_Click(object sender, EventArgs e) iniSavePath.Text = Path.GetDirectoryName(browser.FileName.Trim()); } - private void iconButton2_Click(object sender, EventArgs e) - { + private void iconButton2_Click(object sender, EventArgs e) { SaveFileDialog browser = new SaveFileDialog(); browser.RestoreDirectory = true; browser.Filter = "Directory | directory"; @@ -186,8 +154,7 @@ private void iconButton2_Click(object sender, EventArgs e) javaSavePath.Text = Path.GetDirectoryName(browser.FileName.Trim()); } - private void iconButton3_Click(object sender, EventArgs e) - { + private void iconButton3_Click(object sender, EventArgs e) { SaveFileDialog browser = new SaveFileDialog(); browser.RestoreDirectory = true; browser.Filter = "Directory | directory"; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ShiftPath.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ShiftPath.cs index c325b19..9c0051d 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ShiftPath.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Forms/ShiftPath.cs @@ -9,50 +9,40 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Forms -{ - public partial class ShiftPath : Form - { +namespace MotionProfileMapper.Forms { + public partial class ShiftPath : Form { private ProfilePath path; private Action selectPath; - public ShiftPath(ProfilePath path, Action selectPath) - { + public ShiftPath(ProfilePath path, Action selectPath) { InitializeComponent(); this.path = path; this.selectPath = selectPath; } - private void cancel_Click(object sender, EventArgs e) - { + private void cancel_Click(object sender, EventArgs e) { this.Close(); } - private void shiftButton_Click(object sender, EventArgs e) - { + private void shiftButton_Click(object sender, EventArgs e) { double dx, dy; - if (double.TryParse(dxInput.Text == "" ? "0.0" : dxInput.Text, out dx) && double.TryParse(dyInput.Text == "" ? "0.0" : dyInput.Text, out dy)) - { + if (double.TryParse(dxInput.Text == "" ? "0.0" : dxInput.Text, out dx) && double.TryParse(dyInput.Text == "" ? "0.0" : dyInput.Text, out dy)) { this.path.shiftPoints( dx, dy ); this.selectPath(-1); - } - else - { + } else { MessageBox.Show("Shift values must be numbers", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); } - private void dxInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) shiftButton_Click(null, null); + private void dxInput_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char) Keys.Enter) shiftButton_Click(null, null); } - private void dyInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Enter) shiftButton_Click(null, null); + private void dyInput_KeyPress(object sender, KeyPressEventArgs e) { + if (e.KeyChar == (char) Keys.Enter) shiftButton_Click(null, null); } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Main/Program.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Main/Program.cs index b461953..b832b73 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Main/Program.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Main/Program.cs @@ -4,23 +4,20 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware(); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MotionProfileMapper.Forms.Menu()); - } +namespace MotionProfileMapper { + static class Program { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { + if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MotionProfileMapper.Forms.Menu()); + } - [System.Runtime.InteropServices.DllImport("user32.dll")] - private static extern bool SetProcessDPIAware(); - } + [System.Runtime.InteropServices.DllImport("user32.dll")] + private static extern bool SetProcessDPIAware(); + } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/MessageBoxManager.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/MessageBoxManager.cs index 74169bb..28a75d2 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/MessageBoxManager.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/MessageBoxManager.cs @@ -10,12 +10,9 @@ [assembly: SecurityPermission(SecurityAction.RequestMinimum, UnmanagedCode = true)] -namespace System.Windows.Forms +namespace System.Windows.Forms { -{ - - public class MessageBoxManager - { + public class MessageBoxManager { private delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); private delegate bool EnumChildProc(IntPtr hWnd, IntPtr lParam); @@ -73,8 +70,7 @@ public class MessageBoxManager [StructLayout(LayoutKind.Sequential)] - public struct CWPRETSTRUCT - { + public struct CWPRETSTRUCT { public IntPtr lResult; public IntPtr lParam; public IntPtr wParam; @@ -118,8 +114,7 @@ public struct CWPRETSTRUCT /// public static string No = "&No"; - static MessageBoxManager() - { + static MessageBoxManager() { hookProc = new HookProc(MessageBoxHookProc); enumProc = new EnumChildProc(MessageBoxEnumProc); hHook = IntPtr.Zero; @@ -132,8 +127,7 @@ static MessageBoxManager() /// MessageBoxManager functionality is enabled on current thread only. /// Each thread that needs MessageBoxManager functionality has to call this method. /// - public static void Register() - { + public static void Register() { if (hHook != IntPtr.Zero) throw new NotSupportedException("One hook per thread allowed."); hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId()); @@ -145,34 +139,28 @@ public static void Register() /// /// Disables MessageBoxManager functionality on current thread only. /// - public static void Unregister() - { - if (hHook != IntPtr.Zero) - { + public static void Unregister() { + if (hHook != IntPtr.Zero) { UnhookWindowsHookEx(hHook); hHook = IntPtr.Zero; } } - private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam) - { + private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0) return CallNextHookEx(hHook, nCode, wParam, lParam); - CWPRETSTRUCT msg = (CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(CWPRETSTRUCT)); + CWPRETSTRUCT msg = (CWPRETSTRUCT) Marshal.PtrToStructure(lParam, typeof(CWPRETSTRUCT)); IntPtr hook = hHook; - if (msg.message == WM_INITDIALOG) - { + if (msg.message == WM_INITDIALOG) { int nLength = GetWindowTextLength(msg.hwnd); StringBuilder className = new StringBuilder(10); GetClassName(msg.hwnd, className, className.Capacity); - if (className.ToString() == "#32770") - { + if (className.ToString() == "#32770") { nButton = 0; EnumChildWindows(msg.hwnd, enumProc, IntPtr.Zero); - if (nButton == 1) - { + if (nButton == 1) { IntPtr hButton = GetDlgItem(msg.hwnd, MBCancel); if (hButton != IntPtr.Zero) SetWindowText(hButton, OK); @@ -183,15 +171,12 @@ private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam return CallNextHookEx(hook, nCode, wParam, lParam); } - private static bool MessageBoxEnumProc(IntPtr hWnd, IntPtr lParam) - { + private static bool MessageBoxEnumProc(IntPtr hWnd, IntPtr lParam) { StringBuilder className = new StringBuilder(10); GetClassName(hWnd, className, className.Capacity); - if (className.ToString() == "Button") - { + if (className.ToString() == "Button") { int ctlId = GetDlgCtrlID(hWnd); - switch (ctlId) - { + switch (ctlId) { case MBOK: SetWindowText(hWnd, OK); break; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Motion-Profile-Mapper.csproj b/Motion-Profile-Mapper/Motion-Profile-Mapper/Motion-Profile-Mapper.csproj index 9cf44c6..828f33e 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Motion-Profile-Mapper.csproj +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Motion-Profile-Mapper.csproj @@ -133,12 +133,6 @@ PathSettings.cs - - Form - - - PoseVisualizer.cs - Form @@ -170,7 +164,6 @@ AboutBox.cs - Form @@ -190,7 +183,6 @@ - @@ -206,7 +198,6 @@ - AboutBox.cs @@ -227,9 +218,6 @@ PathSettings.cs - - PoseVisualizer.cs - Preview.cs diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/OutputPoints.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/OutputPoints.cs index 560db5b..1c9d014 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/OutputPoints.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/OutputPoints.cs @@ -4,10 +4,8 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfile -{ - public class OutputPoints - { +namespace MotionProfile { + public class OutputPoints { public List velocity = new List(); public List acceleration = new List(); public List jerk = new List(); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/S_Curve.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/S_Curve.cs deleted file mode 100644 index e210378..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/S_Curve.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MotionProfile -{ - public class S_Curve - { - public double t0; - public double t; - public double j; - public double a; - public double v; - public double p; - public S_Curve(double t0, double t, double j, double a, double v, double p) - { - this.t0 = t0; - this.t = t; - this.j = j; - this.a = a; - this.v = v; - this.p = p; - } - } -} diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/Profile.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/Profile.cs index dd9dff2..bf1b7e3 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/Profile.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/Profile.cs @@ -6,10 +6,8 @@ using System.Threading.Tasks; using MotionProfileMapper; -namespace MotionProfile.SegmentedProfile -{ - public class Profile - { +namespace MotionProfile.SegmentedProfile { + public class Profile { private string name; private string edited; private List paths; @@ -20,8 +18,7 @@ public class Profile /// /// Creates a new blank profile /// - public Profile() - { + public Profile() { this.name = "Profile " + profileCounter++; this.edited = DateTime.Now.ToString("MM/dd/yy, hh:mm:ss tt"); this.paths = new List(); @@ -33,50 +30,41 @@ public Profile() /// Loads a profile from a profile JSON representation /// /// JSON-formatted profile object - public Profile(JObject profileJSON) - { - this.name = (string)profileJSON["name"]; - this.edited = (string)profileJSON["edited"]; + public Profile(JObject profileJSON) { + this.name = (string) profileJSON["name"]; + this.edited = (string) profileJSON["edited"]; this.paths = new List(); - try - { - this.isRed = (bool)profileJSON["isRed"]; - } - catch - { + try { + this.isRed = (bool) profileJSON["isRed"]; + } catch { } - foreach (JObject pathJSON in profileJSON["paths"]) - { + foreach (JObject pathJSON in profileJSON["paths"]) { this.paths.Add(new ProfilePath(pathJSON, this)); } } - public Profile(Profile other) - { + public Profile(Profile other) { this.name = other.name; this.edited = other.edited; this.paths = new List(); this.isRed = other.isRed; - foreach (ProfilePath path in other.paths) - { + foreach (ProfilePath path in other.paths) { this.paths.Add(new ProfilePath(path, this)); } } - public void newPath(string name, bool isSpline, ProfilePath previous = null) - { + public void newPath(string name, bool isSpline, ProfilePath previous = null) { newEdit("New Path"); this.paths.Add(new ProfilePath(this, name, isSpline, previous)); } - public void movePathOrderUp(ProfilePath pathToMove) - { + public void movePathOrderUp(ProfilePath pathToMove) { int pathIndex = this.paths.IndexOf(pathToMove); if (pathIndex < 1) return; @@ -87,8 +75,7 @@ public void movePathOrderUp(ProfilePath pathToMove) this.paths.Insert(pathIndex - 1, temp); } - public void movePathOrderDown(ProfilePath pathToMove) - { + public void movePathOrderDown(ProfilePath pathToMove) { int pathIndex = this.paths.IndexOf(pathToMove); if (pathIndex == -1 || pathIndex == this.paths.Count - 1) return; @@ -98,42 +85,35 @@ public void movePathOrderDown(ProfilePath pathToMove) this.paths.Insert(pathIndex + 1, temp); } - public void mirrorPath(ProfilePath pathToMirror, double fieldHeight) - { + public void mirrorPath(ProfilePath pathToMirror, double fieldHeight) { newEdit("Path Mirror"); int index = this.paths.IndexOf(pathToMirror); this.paths[index].mirrorPoints(fieldHeight); } - public void mirrorAllPaths(double fieldHeight) - { + public void mirrorAllPaths(double fieldHeight) { newEdit("Mirror All Paths"); - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { path.mirrorPoints(fieldHeight); } } - public bool isValid() - { + public bool isValid() { if (this.paths.Count == 0) return false; - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { if (path.ControlPoints.Count < 2) return false; } return true; } - public JObject toJSON() - { + public JObject toJSON() { JObject profile = new JObject(); profile["name"] = this.name; profile["edited"] = this.edited; profile["isRed"] = this.isRed; JArray pathsJSON = new JArray(); - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { pathsJSON.Add(path.toJSON()); } profile["paths"] = pathsJSON; @@ -141,8 +121,7 @@ public JObject toJSON() return profile; } - public string toJava() - { + public string toJava() { string profile = $"public class {this.name.Replace(" ", "").Trim()} extends BBPath \n"; profile += "{\n\tpublic double[][] getConstrains{return constraints;}"; @@ -151,8 +130,7 @@ public string toJava() profile += "\tpublic final double[][] constraints = {\n"; List constraintStrings = new List(); - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { constraintStrings.Add("\t\t{" + $"{path.MaxVel},{path.MaxAcc},{path.MaxCen}" + "}"); } profile += String.Join(",\n", constraintStrings) + "\n"; @@ -161,8 +139,7 @@ public string toJava() profile += "\tpublic final double[][][] paths = {\n"; List pathStrings = new List(); - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { pathStrings.Add(path.toJava()); } profile += String.Join(",\n", pathStrings) + "\n"; @@ -172,71 +149,57 @@ public string toJava() return profile; } - public string toTxt() - { + public string toTxt() { List pathStrings = new List(); - foreach (ProfilePath path in this.paths) - { + foreach (ProfilePath path in this.paths) { pathStrings.Add(path.toTxt()); } return String.Join("\n", pathStrings); } - public void newEdit(string reason) - { + public void newEdit(string reason) { this.edited = DateTime.Now.ToString("MM/dd/yy, hh:mm:ss tt"); MotionProfiler.saveUndoState(reason); MotionProfiler.motionProfiler.updateEditTime(this); } - public void forceEdit() - { + public void forceEdit() { this.edited = DateTime.Now.ToString("MM/dd/yy, hh:mm:ss tt"); MotionProfiler.motionProfiler.updateEditTime(this); } - public string Name - { - get - { + public string Name { + get { return this.name; } - set - { + set { string newName = value.Trim(); if (newName == "") return; - if(newName == this.name) return; + if (newName == this.name) return; newEdit("Name Change"); this.name = newName; } } - public int PathCount - { - get - { + public int PathCount { + get { return this.paths.Count; } } - public String Edited - { - get - { + public String Edited { + get { return this.edited; } } - public List Paths - { - get - { + public List Paths { + get { return this.paths; } - set - { + set { newEdit("Paths Changes"); this.paths = value; } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/ProfilePath.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/ProfilePath.cs index 4768a80..b700cb3 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/ProfilePath.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/SegmentedProfile/ProfilePath.cs @@ -11,10 +11,8 @@ using MotionProfileMapper; using MotionProfileMapper.VelocityGenerate; -namespace MotionProfile.SegmentedProfile -{ - public class ProfilePath - { +namespace MotionProfile.SegmentedProfile { + public class ProfilePath { private string name; private List controlPoints; private string id; @@ -42,8 +40,7 @@ public class ProfilePath /// /// Creates a new blank profile path /// - public ProfilePath(Profile profile, string name, bool isSpline, ProfilePath previousPath = null) - { + public ProfilePath(Profile profile, string name, bool isSpline, ProfilePath previousPath = null) { this.profile = profile; this.name = name; this.controlPoints = new List(); @@ -57,52 +54,39 @@ public ProfilePath(Profile profile, string name, bool isSpline, ProfilePath prev /// Loads a profile path from a path JSON representation /// /// JSON-formatted path object - public ProfilePath(JObject pathJSON, Profile profile) - { + public ProfilePath(JObject pathJSON, Profile profile) { this.profile = profile; - this.name = (string)pathJSON["name"]; + this.name = (string) pathJSON["name"]; this.id = Guid.NewGuid().ToString(); - this.maxVel = (double)pathJSON["maxVelocity"]; - this.maxAcc = (double)pathJSON["maxAcceleration"]; - try - { - this.inVel = (double)pathJSON["inVelocity"]; - } - catch { } - try - { - this.outVel = (double)pathJSON["outVelocity"]; - } - catch{ } - try - { - this.maxCen = (double)pathJSON["maxCentripetalAcceleration"]; - } - catch - { + this.maxVel = (double) pathJSON["maxVelocity"]; + this.maxAcc = (double) pathJSON["maxAcceleration"]; + try { + this.inVel = (double) pathJSON["inVelocity"]; + } catch { } + try { + this.outVel = (double) pathJSON["outVelocity"]; + } catch { } + try { + this.maxCen = (double) pathJSON["maxCentripetalAcceleration"]; + } catch { } - try - { - this.isSpline = (bool)pathJSON["isSpline"]; - } - catch - { + try { + this.isSpline = (bool) pathJSON["isSpline"]; + } catch { } this.snapToPrevious = pathJSON.ContainsKey("snapToPrevious") ? - (bool)pathJSON["snapToPrevious"] : false; + (bool) pathJSON["snapToPrevious"] : false; this.controlPoints = new List(); - foreach (JObject point in pathJSON["points"]) - { + foreach (JObject point in pathJSON["points"]) { this.controlPoints.Add(new ControlPoint(point, this)); } } - public ProfilePath(ProfilePath other, Profile profile) - { + public ProfilePath(ProfilePath other, Profile profile) { this.profile = profile; this.name = other.name; this.isSpline = other.isSpline; @@ -115,90 +99,74 @@ public ProfilePath(ProfilePath other, Profile profile) this.inVel = other.inVel; this.outVel = other.outVel; - foreach (ControlPoint point in other.controlPoints) - { + foreach (ControlPoint point in other.controlPoints) { this.controlPoints.Add(new ControlPoint(point, this)); } } //Call before edit. - public void newEdit(string reason) - { + public void newEdit(string reason) { profile.newEdit(reason); } - public ControlPoint addControlPoint(int x, int y, int heading) - { + public ControlPoint addControlPoint(int x, int y, int heading) { newEdit("Path Add Control Point"); ControlPoint newPoint = new ControlPoint(this, x, y, heading); this.controlPoints.Add(newPoint); return newPoint; } - public ControlPoint addControlPoint(ControlPoint other) - { + public ControlPoint addControlPoint(ControlPoint other) { newEdit("Path Add Control Point"); ControlPoint newPoint = new ControlPoint(other, this); this.controlPoints.Add(newPoint); return newPoint; } - public void deleteControlPoint(int index) - { + public void deleteControlPoint(int index) { newEdit("Path Delete Control Point"); this.controlPoints.RemoveAt(index); if (this.controlPoints.Count == 0) this.snapToPrevious = false; } - public List pointIds() - { + public List pointIds() { List ids = new List(); - foreach (ControlPoint point in this.controlPoints) - { + foreach (ControlPoint point in this.controlPoints) { ids.Add(point.Id); } return ids; } - public void mirrorPoints(double fieldHeight) - { + public void mirrorPoints(double fieldHeight) { newEdit("Path Mirror Points"); - foreach (ControlPoint point in this.controlPoints) - { + foreach (ControlPoint point in this.controlPoints) { //point.quickChangeX(fieldWidth - point.X); point.quickChangeY(fieldHeight - point.Y); } - foreach (ControlPoint p in this.controlPoints) - { + foreach (ControlPoint p in this.controlPoints) { p.quickChangeRotation(-p.Rotation); } } - public void shiftPoints(double dx, double dy) - { + public void shiftPoints(double dx, double dy) { newEdit("Path Shift Points"); - foreach (ControlPoint point in this.controlPoints) - { + foreach (ControlPoint point in this.controlPoints) { point.X += dx; point.Y += dy; } } - public void reverse() - { + public void reverse() { newEdit("Path Reverse Points"); this.controlPoints.Reverse(); } - public void clearPoints() - { + public void clearPoints() { newEdit("Path Clear Points"); this.controlPoints.Clear(); } - public void snap(ProfilePath previous) - { + public void snap(ProfilePath previous) { - if (previous == null || previous.controlPoints.Count == 0) - { + if (previous == null || previous.controlPoints.Count == 0) { this.snapToPrevious = false; return; } @@ -208,15 +176,13 @@ public void snap(ProfilePath previous) else this.controlPoints[0] = new ControlPoint(previous.controlPoints.Last(), this); } - public void snapLast(ControlPoint point) - { + public void snapLast(ControlPoint point) { if (this.controlPoints.Count == 0) return; this.controlPoints[this.controlPoints.Count - 1] = new ControlPoint(point, this); } - public bool isEmpty() - { + public bool isEmpty() { if (length == 0.0) return true; @@ -228,12 +194,10 @@ public bool isEmpty() private double length = 0.0; - public void generate(bool quickGen = false) - { + public void generate(bool quickGen = false) { double timeSample = 0.05; double sampleDistance = 0.05; - if (quickGen) - { + if (quickGen) { timeSample = 0.1; sampleDistance = 0.2; } @@ -243,8 +207,7 @@ public void generate(bool quickGen = false) pointList.Clear(); cpdistances.Clear(); - if (controlPoints.Count < 2) - { + if (controlPoints.Count < 2) { cpdistances.Add(0.0); return; } @@ -252,17 +215,13 @@ public void generate(bool quickGen = false) TrajectoryConstraint[] constraints = { new MaxAccelerationConstraint(this.maxAcc), new MaxVelocityConstraint(this.maxVel), new CentripetalAccelerationConstraint(this.maxCen) }; - if (isSpline) - { - + if (isSpline) { + path.GenSpline(this.controlPoints); length = path.getLength(); cpdistances = path.getControlPointDistances(); - } - - else - { + } else { length = 0; List distances = new List(); @@ -270,15 +229,13 @@ public void generate(bool quickGen = false) List ys = new List(); cpdistances.Add(0.0); - for (int i = 0; i < controlPoints.Count - 1; i++) - { + for (int i = 0; i < controlPoints.Count - 1; i++) { ControlPoint p1 = controlPoints[i]; ControlPoint p2 = controlPoints[i + 1]; length += Math.Sqrt(Math.Pow(p2.X - p1.X, 2) + Math.Pow(p2.Y - p1.Y, 2)); cpdistances.Add(length); } - for (int i = 0; i < cpdistances.Count; i++) - { + for (int i = 0; i < cpdistances.Count; i++) { distances.Add(cpdistances[i]); xs.Add(this.controlPoints[i].X); ys.Add(this.controlPoints[i].Y); @@ -289,27 +246,22 @@ public void generate(bool quickGen = false) } gen = new VelocityGeneration(this, constraints, sampleDistance, this.inVel, this.outVel); - for (double time = 0; time < gen.getDuration(); time += timeSample) - { + for (double time = 0; time < gen.getDuration(); time += timeSample) { State s = gen.calculate(time); pointList.Add(s); } } - public PState calculate(double distance) - { - if (controlPoints.Count == 0) - { + public PState calculate(double distance) { + if (controlPoints.Count == 0) { throw new Exception("No Path To Calculate"); } - if (controlPoints.Count == 1) - { + if (controlPoints.Count == 1) { ControlPoint p = controlPoints[0]; return new PState(distance, new Pose2d(p.X, p.Y, p.getRotation2d()), p.getRotation2d(), p.Radius); } - if (isSpline) - { + if (isSpline) { SplinePoint p = path.calculate(distance); double distance1 = 0.0; @@ -319,17 +271,14 @@ public PState calculate(double distance) SplinePoint p2 = null; SplinePoint p3 = null; - if (distance > sampleDistance) - { + if (distance > sampleDistance) { distance1 = distance - sampleDistance; distance2 = distance + sampleDistance; p1 = path.calculate(distance1); p2 = path.calculate(distance); p3 = path.calculate(distance2); - } - else - { + } else { distance1 = distance + sampleDistance; distance2 = distance + sampleDistance * 2; p1 = path.calculate(distance); @@ -352,9 +301,7 @@ public PState calculate(double distance) return new PState(distance, new Pose2d(p.X, p.Y, rot), Rotation2d.fromRadians(Math.Atan2(p2.Y - p1.Y, p2.X - p1.X)), r); - } - else - { + } else { SplinePoint p = linearInterpolation(distance); double distance1 = 0.0; @@ -364,17 +311,14 @@ public PState calculate(double distance) SplinePoint p2 = null; SplinePoint p3 = null; - if (distance > sampleDistance) - { + if (distance > sampleDistance) { distance1 = distance - sampleDistance; distance2 = distance + sampleDistance; p1 = linearInterpolation(distance1); p2 = linearInterpolation(distance); p3 = linearInterpolation(distance2); - } - else - { + } else { distance1 = distance + sampleDistance; distance2 = distance + sampleDistance * 2; p1 = linearInterpolation(distance); @@ -397,29 +341,23 @@ public PState calculate(double distance) } } - private int getCurrentControlPointIndex(double distance) - { - if (distance == length) - { + private int getCurrentControlPointIndex(double distance) { + if (distance == length) { return cpdistances.Count - 2; } int index = -1; - for (int i = 0; i < cpdistances.Count; i++) - { + for (int i = 0; i < cpdistances.Count; i++) { double dist = cpdistances[i]; if (dist <= distance) index = i; } return index; } - private int getNextControlPointIndex(double distance) - { - if (distance == length) - { + private int getNextControlPointIndex(double distance) { + if (distance == length) { return cpdistances.Count - 1; } - for (int i = 0; i < cpdistances.Count; i++) - { + for (int i = 0; i < cpdistances.Count; i++) { double dist = cpdistances[i]; if (dist > distance) return i; @@ -429,45 +367,40 @@ private int getNextControlPointIndex(double distance) } - private SplinePoint linearInterpolation(double distance) - { + private SplinePoint linearInterpolation(double distance) { if (isSpline) return null; return new SplinePoint(xsMap.Interpolate(distance), ysMap.Interpolate(distance)); } static double TOL = 0.0000001; - private double circleFromPoints(SplinePoint p1, SplinePoint p2, SplinePoint p3) - { + private double circleFromPoints(SplinePoint p1, SplinePoint p2, SplinePoint p3) { double offset = Math.Pow(p2.X, 2) + Math.Pow(p2.Y, 2); - double bc = (Math.Pow(p1.X, 2) + Math.Pow(p1.Y, 2) - offset) / 2.0; - double cd = (offset - Math.Pow(p3.X, 2) - Math.Pow(p3.Y, 2)) / 2.0; - double det = (p1.X - p2.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p2.Y); + double bc = ( Math.Pow(p1.X, 2) + Math.Pow(p1.Y, 2) - offset ) / 2.0; + double cd = ( offset - Math.Pow(p3.X, 2) - Math.Pow(p3.Y, 2) ) / 2.0; + double det = ( p1.X - p2.X ) * ( p2.Y - p3.Y ) - ( p2.X - p3.X ) * ( p1.Y - p2.Y ); if (Math.Abs(det) < TOL) { return double.PositiveInfinity; } double idet = 1 / det; - double centerx = (bc * (p2.Y - p3.Y) - cd * (p1.Y - p2.Y)) * idet; - double centery = (cd * (p1.X - p2.X) - bc * (p2.X - p3.X)) * idet; + double centerx = ( bc * ( p2.Y - p3.Y ) - cd * ( p1.Y - p2.Y ) ) * idet; + double centery = ( cd * ( p1.X - p2.X ) - bc * ( p2.X - p3.X ) ) * idet; double radius = Math.Sqrt(Math.Pow(p2.X - centerx, 2) + Math.Pow(p2.Y - centery, 2)); return radius; } - public double getLength() - { + public double getLength() { return length; } - public List getPoints() - { + public List getPoints() { return pointList; } - public JObject toJSON() - { + public JObject toJSON() { JObject pathJSON = new JObject(); pathJSON["name"] = this.name; pathJSON["id"] = this.id; @@ -480,8 +413,7 @@ public JObject toJSON() pathJSON["snapToPrevious"] = this.snapToPrevious; JArray pointsJSON = new JArray(); - foreach (ControlPoint point in this.controlPoints) - { + foreach (ControlPoint point in this.controlPoints) { pointsJSON.Add(point.toJSON()); } pathJSON["points"] = pointsJSON; @@ -489,34 +421,26 @@ public JObject toJSON() return pathJSON; } - public string toJava() - { + public string toJava() { string path = "\t\t{\n"; List pointStrings = new List(); this.generate(); - if (isSpline) - { - if (pointList.Count == 0) - { + if (isSpline) { + if (pointList.Count == 0) { MessageBox.Show("Error no points to export.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return ""; } List tmpCTL = new List(); - foreach (State s in pointList) - { + foreach (State s in pointList) { Pose2d pose = s.getPathState().getPose2d(); tmpCTL.Add(new ControlPoint(this, pose.getX(), pose.getY(), pose.getRotation().getDegrees(), s.getPathState().getRadius())); } - foreach (ControlPoint point in tmpCTL) - { + foreach (ControlPoint point in tmpCTL) { pointStrings.Add(point.toJava()); } - } - else - { - foreach (ControlPoint point in this.controlPoints) - { + } else { + foreach (ControlPoint point in this.controlPoints) { pointStrings.Add(point.toJava()); } @@ -527,34 +451,26 @@ public string toJava() return path; } - public string toTxt() - { + public string toTxt() { this.generate(); string pathTxt = $"{this.maxVel} {this.maxAcc} {this.maxCen} {this.inVel} {this.outVel}\n"; - if (isSpline) - { - if (pointList.Count == 0) - { + if (isSpline) { + if (pointList.Count == 0) { MessageBox.Show("Error no points to export.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return ""; } List tmpCTL = new List(); - foreach (State s in pointList) - { + foreach (State s in pointList) { Pose2d pose = s.getPathState().getPose2d(); tmpCTL.Add(new ControlPoint(this, pose.getX(), pose.getY(), pose.getRotation().getDegrees(), s.getPathState().getRadius())); } - foreach (ControlPoint point in tmpCTL) - { + foreach (ControlPoint point in tmpCTL) { pathTxt += point.toTxt(); } return pathTxt + "@@@"; - } - else - { - foreach (ControlPoint point in this.controlPoints) - { + } else { + foreach (ControlPoint point in this.controlPoints) { pathTxt += point.toTxt(); } return pathTxt + "@@@"; @@ -563,8 +479,7 @@ public string toTxt() } - public void updateAll(string name, bool snapToPrevious, double vel, double inVel, double outVel, double acc, double cen) - { + public void updateAll(string name, bool snapToPrevious, double vel, double inVel, double outVel, double acc, double cen) { if (this.name != name || this.snapToPrevious != snapToPrevious || this.maxVel != vel || this.inVel != inVel || this.outVel != outVel || this.MaxAcc != acc || this.maxCen != cen) newEdit("Path Update Settings"); this.maxVel = vel; @@ -577,17 +492,13 @@ public void updateAll(string name, bool snapToPrevious, double vel, double inVel } - public string Name - { - get - { + public string Name { + get { return this.name; } - set - { + set { if (value.Trim() == "") return; - if (value.Trim() != this.name) - { + if (value.Trim() != this.name) { newEdit("Path Name Change"); MotionProfiler.saveUndoState("Path Name Change"); this.name = value.Trim(); @@ -595,139 +506,103 @@ public string Name } } - public string Id - { - get - { + public string Id { + get { return this.id; } - set - { - if (this.id != value) - { + set { + if (this.id != value) { newEdit("Path ID Change"); this.id = value; } } } - public bool IsSpline - { - get - { + public bool IsSpline { + get { return this.isSpline; } - set - { - if (this.isSpline != value) - { + set { + if (this.isSpline != value) { newEdit("Path Spline Mode Change"); this.isSpline = value; } } } - public double MaxVel - { - get - { + public double MaxVel { + get { return this.maxVel; } - set - { - if (this.maxVel != value) - { + set { + if (this.maxVel != value) { newEdit("Path Max Vel Change"); this.maxVel = value; } } } - public double InVel - { - get - { + public double InVel { + get { return this.inVel; } - set - { - if (this.inVel != value) - { + set { + if (this.inVel != value) { newEdit("Path In Vel Change"); this.inVel = value; } } } - public double OutVel - { - get - { + public double OutVel { + get { return this.outVel; } - set - { - if (this.outVel != value) - { + set { + if (this.outVel != value) { newEdit("Path Out Vel Change"); this.outVel = value; } } } - public double MaxAcc - { - get - { + public double MaxAcc { + get { return this.maxAcc; } - set - { - if (this.maxAcc != value) - { + set { + if (this.maxAcc != value) { newEdit("Path Max Accel Change"); this.maxAcc = value; } } } - public double MaxCen - { - get - { + public double MaxCen { + get { return this.maxCen; } - set - { - if (this.maxCen != value) - { + set { + if (this.maxCen != value) { newEdit("Path Max Cen Change"); this.maxCen = value; } } } - public bool SnapToPrevious - { - get - { + public bool SnapToPrevious { + get { return this.snapToPrevious; } - set - { - if (this.snapToPrevious != value) - { + set { + if (this.snapToPrevious != value) { newEdit("Path Snap To Previous Change"); this.snapToPrevious = value; } } } - public List ControlPoints - { - get - { + public List ControlPoints { + get { return this.controlPoints; } - set - { - if (this.controlPoints != value) - { + set { + if (this.controlPoints != value) { newEdit("Path Control Points Change"); this.controlPoints = value; } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ArrayUtil.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ArrayUtil.cs index c1bf377..d85ebd2 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ArrayUtil.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ArrayUtil.cs @@ -1,36 +1,29 @@ using System; using System.Text; -namespace MotionProfile.Spline -{ - /// - /// Utility methods for arrays. - /// - public static class ArrayUtil - { - /// - /// Create a string to display the array values. - /// - /// The array - /// Optional. A string to use to format each value. Must contain the colon, so something like ':0.000' - public static string ToString(T[] array, string format = "") - { - var s = new StringBuilder(); - string formatString = "{0" + format + "}"; +namespace MotionProfile.Spline { + /// + /// Utility methods for arrays. + /// + public static class ArrayUtil { + /// + /// Create a string to display the array values. + /// + /// The array + /// Optional. A string to use to format each value. Must contain the colon, so something like ':0.000' + public static string ToString(T[] array, string format = "") { + var s = new StringBuilder(); + string formatString = "{0" + format + "}"; - for (int i = 0; i < array.Length; i++) - { - if (i < array.Length - 1) - { - s.AppendFormat(formatString + ", ", array[i]); - } - else - { - s.AppendFormat(formatString, array[i]); - } - } + for (int i = 0; i < array.Length; i++) { + if (i < array.Length - 1) { + s.AppendFormat(formatString + ", ", array[i]); + } else { + s.AppendFormat(formatString, array[i]); + } + } - return s.ToString(); - } - } + return s.ToString(); + } + } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPoint.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPoint.cs index 690ca33..1a547f4 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPoint.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPoint.cs @@ -7,10 +7,8 @@ using System.Threading.Tasks; using MotionProfileMapper.VelocityGenerate; -namespace MotionProfile -{ - public class ControlPoint - { +namespace MotionProfile { + public class ControlPoint { private double x; private double y; private double rotation; @@ -23,8 +21,7 @@ public class ControlPoint /// /// Creates a new control point based on coordinates /// - public ControlPoint(ProfilePath path, double x, double y, double rotation) - { + public ControlPoint(ProfilePath path, double x, double y, double rotation) { this.path = path; this.x = x; this.y = y; @@ -32,8 +29,7 @@ public ControlPoint(ProfilePath path, double x, double y, double rotation) this.id = Guid.NewGuid().ToString(); radius = double.PositiveInfinity; } - public ControlPoint(ProfilePath path, double x, double y, double rotation, double radius) - { + public ControlPoint(ProfilePath path, double x, double y, double rotation, double radius) { this.path = path; this.x = x; this.y = y; @@ -42,17 +38,14 @@ public ControlPoint(ProfilePath path, double x, double y, double rotation, doubl this.id = Guid.NewGuid().ToString(); } - public bool Equals(ControlPoint other) - { - if (this.x == other.x && this.y == other.y && this.rotation == other.rotation) - { + public bool Equals(ControlPoint other) { + if (this.x == other.x && this.y == other.y && this.rotation == other.rotation) { return true; } return false; } - public Rotation2d getRotation2d() - { + public Rotation2d getRotation2d() { return Rotation2d.fromDegrees(rotation); } @@ -60,8 +53,7 @@ public Rotation2d getRotation2d() /// Creates a control point copy from another control point /// /// ControlPoint object to copy - public ControlPoint(ControlPoint other, ProfilePath path) - { + public ControlPoint(ControlPoint other, ProfilePath path) { this.path = path; this.x = other.X; this.y = other.Y; @@ -74,20 +66,18 @@ public ControlPoint(ControlPoint other, ProfilePath path) /// Loads a control point from a point JSON representation /// /// JSON-formatted point object - public ControlPoint(JObject pointJSON, ProfilePath path) - { + public ControlPoint(JObject pointJSON, ProfilePath path) { this.path = path; - this.x = (double)pointJSON["x"]; - this.y = (double)pointJSON["y"]; - this.rotation = (double)pointJSON["rotation"]; - this.id = (string)pointJSON["id"]; + this.x = (double) pointJSON["x"]; + this.y = (double) pointJSON["y"]; + this.rotation = (double) pointJSON["rotation"]; + this.id = (string) pointJSON["id"]; } /// /// Parses the ControlPoint into JSON format /// - public JObject toJSON() - { + public JObject toJSON() { JObject pointJSON = new JObject(); pointJSON["x"] = this.X; pointJSON["y"] = this.Y; @@ -96,123 +86,96 @@ public JObject toJSON() return pointJSON; } - public void newEdit(string reason) - { + public void newEdit(string reason) { path.newEdit(reason); } - public string toJava() - { + public string toJava() { if (Double.IsInfinity(this.Radius)) return $"\t\t\t{{{this.X}, {this.Y}, {this.Rotation}, Double.POSITIVE_INFINITY}}"; return $"\t\t\t{{{this.X}, {this.Y}, {this.Rotation}, {this.Radius}}}"; } - public string toTxt() - { + public string toTxt() { if (Double.IsInfinity(this.Radius)) return $"{this.X} {this.Y} {this.Rotation} Infinity\n"; return $"{this.X} {this.Y} {this.Rotation} {this.Radius}\n"; } - public double Radius - { - get - { + public double Radius { + get { return Math.Round(this.radius, 5); } } - public double Rotation - { - get - { + public double Rotation { + get { return Math.Round(this.rotation, 5); } - set - { + set { newEdit("Control Point Rotation Change"); this.rotation = value; } } - public void quickChangeX(double x) - { + public void quickChangeX(double x) { this.x = x; } - public void quickChangeY(double y) - { + public void quickChangeY(double y) { this.y = y; } - public void quickChangeRotation(double rotation) - { + public void quickChangeRotation(double rotation) { this.rotation = rotation; } - public double X - { - get - { + public double X { + get { return Math.Round(this.x, 5); } - set - { - if (value != this.x) - { + set { + if (value != this.x) { newEdit("Control Point X Change"); this.x = value; } } } - public double Y - { - get - { + public double Y { + get { return Math.Round(this.y, 5); } - set - { - if (value != this.y) - { + set { + if (value != this.y) { newEdit("Control Point Y Change"); this.y = value; } } } - public float Velocity - { - get - { + public float Velocity { + get { return this.velocity; } - set - { - if (this.velocity != value) - { + set { + if (this.velocity != value) { newEdit("Control Point Velocity Change"); this.velocity = value; } } } - public string Id - { - get - { + public string Id { + get { return this.id; } } - public ProfilePath Path - { - get - { + public ProfilePath Path { + get { return this.path; } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPointSegment.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPointSegment.cs index d80eca8..0b1dd17 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPointSegment.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/ControlPointSegment.cs @@ -4,10 +4,8 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfile.Spline -{ - public class ControlPointSegment - { +namespace MotionProfile.Spline { + public class ControlPointSegment { public List points = new List(); public ControlPoint startPoint; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/SplinePath.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/SplinePath.cs index a1ebf5d..d7ed2e6 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/SplinePath.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/SplinePath.cs @@ -6,35 +6,30 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfile.Spline -{ - public class SplinePath - { +namespace MotionProfile.Spline { + public class SplinePath { ParametricSpline spline; List CPDistances = new List(); List points = null; double length = 0; - public void GenSpline(List points) - { + public void GenSpline(List points) { this.points = points; List xs = new List(); List ys = new List(); - foreach (ControlPoint point in points) - { + foreach (ControlPoint point in points) { xs.Add(point.X); ys.Add(point.Y); } double totalDist = 0; double[] ctlDists = new double[xs.Count]; - for (int i = 1; i < xs.Count; i++) - { + for (int i = 1; i < xs.Count; i++) { double dx = xs[i] - xs[i - 1]; double dy = ys[i] - ys[i - 1]; - double dist = (double)Math.Sqrt(dx * dx + dy * dy); + double dist = (double) Math.Sqrt(dx * dx + dy * dy); totalDist += dist; ctlDists[i] = totalDist; } @@ -44,18 +39,14 @@ public void GenSpline(List points) int index = 0; List ctlPointIndexs = new List(); - for (double dist = 0.0; dist < totalDist; dist += stepSize) - { + for (double dist = 0.0; dist < totalDist; dist += stepSize) { dists.Add(dist); index++; - foreach(double ctldist in ctlDists) - { - if (ctldist == dist) - { - ctlPointIndexs.Add(index-1); + foreach (double ctldist in ctlDists) { + if (ctldist == dist) { + ctlPointIndexs.Add(index - 1); } - if (ctldist>dist && ctldist dist && ctldist < dist + stepSize) { dists.Add(ctldist); ctlPointIndexs.Add(index); index++; @@ -70,15 +61,12 @@ public void GenSpline(List points) CPDistances.Clear(); double l = 0.0; - if(ctlPointIndexs.Contains(0)) - { + if (ctlPointIndexs.Contains(0)) { CPDistances.Add(l); } - for (int i = 1; i < splinePoints.Count; i++) - { + for (int i = 1; i < splinePoints.Count; i++) { l += GetDistance(splinePoints[i - 1], splinePoints[i]); - if (ctlPointIndexs.Contains(i)) - { + if (ctlPointIndexs.Contains(i)) { CPDistances.Add(l); } } @@ -91,29 +79,24 @@ public void GenSpline(List points) spline = new ParametricSpline(x1.ToArray(), y1.ToArray()); } - public SplinePoint calculate(double distance) - { + public SplinePoint calculate(double distance) { SplinePoint spoint = spline.Eval(distance); return spoint; } - private double GetDistance(SplinePoint p1, SplinePoint p2) - { + private double GetDistance(SplinePoint p1, SplinePoint p2) { return GetDistance(p1.X, p1.Y, p2.X, p2.Y); } - public List getControlPointDistances() - { + public List getControlPointDistances() { return CPDistances; } - private double GetDistance(double x1, double y1, double x2, double y2) - { - return Math.Sqrt(Math.Pow((x2 - x1), 2.0) + Math.Pow((y2 - y1), 2.0)); + private double GetDistance(double x1, double y1, double x2, double y2) { + return Math.Sqrt(Math.Pow(( x2 - x1 ), 2.0) + Math.Pow(( y2 - y1 ), 2.0)); } - public double getLength() - { + public double getLength() { return length; } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/TriDiagonalMatrix.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/TriDiagonalMatrix.cs index 524fa01..355a61a 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/TriDiagonalMatrix.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Spline/TriDiagonalMatrix.cs @@ -28,187 +28,156 @@ using System.Diagnostics; using System.Text; -namespace MotionProfile.Spline -{ - /// - /// A tri-diagonal matrix has non-zero entries only on the main diagonal, the diagonal above the main (super), and the - /// diagonal below the main (sub). - /// - /// - /// - /// This is based on the wikipedia article: http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm - /// - /// - /// The entries in the matrix on a particular row are A[i], B[i], and C[i] where i is the row index. - /// B is the main diagonal, and so for an NxN matrix B is length N and all elements are used. - /// So for row 0, the first two values are B[0] and C[0]. - /// And for row N-1, the last two values are A[N-1] and B[N-1]. - /// That means that A[0] is not actually on the matrix and is therefore never used, and same with C[N-1]. - /// - /// - public class TriDiagonalMatrixF - { - /// - /// The values for the sub-diagonal. A[0] is never used. - /// - public double[] A; - - /// - /// The values for the main diagonal. - /// - public double[] B; - - /// - /// The values for the super-diagonal. C[C.Length-1] is never used. - /// - public double[] C; - - /// - /// The width and height of this matrix. - /// - public int N - { - get { return (A != null ? A.Length : 0); } - } - - /// - /// Indexer. Setter throws an exception if you try to set any not on the super, main, or sub diagonals. - /// - public double this[int row, int col] - { - get - { - int di = row - col; - - if (di == 0) - { - return B[row]; - } - else if (di == -1) - { - Debug.Assert(row < N - 1); - return C[row]; - } - else if (di == 1) - { - Debug.Assert(row > 0); - return A[row]; - } - else return 0; - } - set - { - int di = row - col; - - if (di == 0) - { - B[row] = value; - } - else if (di == -1) - { - Debug.Assert(row < N - 1); - C[row] = value; - } - else if (di == 1) - { - Debug.Assert(row > 0); - A[row] = value; - } - else - { - throw new ArgumentException("Only the main, super, and sub diagonals can be set."); - } - } - } - - /// - /// Construct an NxN matrix. - /// - public TriDiagonalMatrixF(int n) - { - this.A = new double[n]; - this.B = new double[n]; - this.C = new double[n]; - } - - /// - /// Produce a string representation of the contents of this matrix. - /// - /// Optional. For String.Format. Must include the colon. Examples are ':0.000' and ',5:0.00' - /// Optional. Per-line indentation prefix. - public string ToDisplayString(string fmt = "", string prefix = "") - { - if (this.N > 0) - { - var s = new StringBuilder(); - string formatString = "{0" + fmt + "}"; - - for (int r = 0; r < N; r++) - { - s.Append(prefix); - - for (int c = 0; c < N; c++) - { - s.AppendFormat(formatString, this[r, c]); - if (c < N - 1) s.Append(", "); - } - - s.AppendLine(); - } - - return s.ToString(); - } - else - { - return prefix + "0x0 Matrix"; - } - } - - /// - /// Solve the system of equations this*x=d given the specified d. - /// - /// - /// Uses the Thomas algorithm described in the wikipedia article: http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm - /// Not optimized. Not destructive. - /// - /// Right side of the equation. - public double[] Solve(double[] d) - { - int n = this.N; - - if (d.Length != n) - { - throw new ArgumentException("The input d is not the same size as this matrix."); - } - - // cPrime - double[] cPrime = new double[n]; - cPrime[0] = C[0] / B[0]; - - for (int i = 1; i < n; i++) - { - cPrime[i] = C[i] / (B[i] - cPrime[i-1] * A[i]); - } - - // dPrime - double[] dPrime = new double[n]; - dPrime[0] = d[0] / B[0]; - - for (int i = 1; i < n; i++) - { - dPrime[i] = (d[i] - dPrime[i-1]*A[i]) / (B[i] - cPrime[i - 1] * A[i]); - } - - // Back substitution - double[] x = new double[n]; - x[n - 1] = dPrime[n - 1]; - - for (int i = n-2; i >= 0; i--) - { - x[i] = dPrime[i] - cPrime[i] * x[i + 1]; - } - - return x; - } - } +namespace MotionProfile.Spline { + /// + /// A tri-diagonal matrix has non-zero entries only on the main diagonal, the diagonal above the main (super), and the + /// diagonal below the main (sub). + /// + /// + /// + /// This is based on the wikipedia article: http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm + /// + /// + /// The entries in the matrix on a particular row are A[i], B[i], and C[i] where i is the row index. + /// B is the main diagonal, and so for an NxN matrix B is length N and all elements are used. + /// So for row 0, the first two values are B[0] and C[0]. + /// And for row N-1, the last two values are A[N-1] and B[N-1]. + /// That means that A[0] is not actually on the matrix and is therefore never used, and same with C[N-1]. + /// + /// + public class TriDiagonalMatrixF { + /// + /// The values for the sub-diagonal. A[0] is never used. + /// + public double[] A; + + /// + /// The values for the main diagonal. + /// + public double[] B; + + /// + /// The values for the super-diagonal. C[C.Length-1] is never used. + /// + public double[] C; + + /// + /// The width and height of this matrix. + /// + public int N { + get { return ( A != null ? A.Length : 0 ); } + } + + /// + /// Indexer. Setter throws an exception if you try to set any not on the super, main, or sub diagonals. + /// + public double this[int row, int col] { + get { + int di = row - col; + + if (di == 0) { + return B[row]; + } else if (di == -1) { + Debug.Assert(row < N - 1); + return C[row]; + } else if (di == 1) { + Debug.Assert(row > 0); + return A[row]; + } else return 0; + } + set { + int di = row - col; + + if (di == 0) { + B[row] = value; + } else if (di == -1) { + Debug.Assert(row < N - 1); + C[row] = value; + } else if (di == 1) { + Debug.Assert(row > 0); + A[row] = value; + } else { + throw new ArgumentException("Only the main, super, and sub diagonals can be set."); + } + } + } + + /// + /// Construct an NxN matrix. + /// + public TriDiagonalMatrixF(int n) { + this.A = new double[n]; + this.B = new double[n]; + this.C = new double[n]; + } + + /// + /// Produce a string representation of the contents of this matrix. + /// + /// Optional. For String.Format. Must include the colon. Examples are ':0.000' and ',5:0.00' + /// Optional. Per-line indentation prefix. + public string ToDisplayString(string fmt = "", string prefix = "") { + if (this.N > 0) { + var s = new StringBuilder(); + string formatString = "{0" + fmt + "}"; + + for (int r = 0; r < N; r++) { + s.Append(prefix); + + for (int c = 0; c < N; c++) { + s.AppendFormat(formatString, this[r, c]); + if (c < N - 1) s.Append(", "); + } + + s.AppendLine(); + } + + return s.ToString(); + } else { + return prefix + "0x0 Matrix"; + } + } + + /// + /// Solve the system of equations this*x=d given the specified d. + /// + /// + /// Uses the Thomas algorithm described in the wikipedia article: http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm + /// Not optimized. Not destructive. + /// + /// Right side of the equation. + public double[] Solve(double[] d) { + int n = this.N; + + if (d.Length != n) { + throw new ArgumentException("The input d is not the same size as this matrix."); + } + + // cPrime + double[] cPrime = new double[n]; + cPrime[0] = C[0] / B[0]; + + for (int i = 1; i < n; i++) { + cPrime[i] = C[i] / ( B[i] - cPrime[i - 1] * A[i] ); + } + + // dPrime + double[] dPrime = new double[n]; + dPrime[0] = d[0] / B[0]; + + for (int i = 1; i < n; i++) { + dPrime[i] = ( d[i] - dPrime[i - 1] * A[i] ) / ( B[i] - cPrime[i - 1] * A[i] ); + } + + // Back substitution + double[] x = new double[n]; + x[n - 1] = dPrime[n - 1]; + + for (int i = n - 2; i >= 0; i--) { + x[i] = dPrime[i] - cPrime[i] * x[i + 1]; + } + + return x; + } + } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/UndoHolder.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/UndoHolder.cs index c8be989..6151d97 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/UndoHolder.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/UndoHolder.cs @@ -5,10 +5,8 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper -{ - public class UndoHolder - { +namespace MotionProfileMapper { + public class UndoHolder { public int selectedProfileIndex = -1; public int selectedPathIndex = -1; public List profiles = new List(); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs index 393ab32..79e84ee 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INI.cs @@ -5,40 +5,33 @@ using System.Threading.Tasks; using System.Windows.Forms; -namespace MotionProfileMapper.Utilities -{ - class INI - { +namespace MotionProfileMapper.Utilities { + class INI { public string fileName { get; set; } public List variables; - public INI(string fileName, System.IO.StreamReader reader) - { + public INI(string fileName, System.IO.StreamReader reader) { this.fileName = fileName; this.variables = new List(); - + string currentSection = ""; - while (!reader.EndOfStream) - { + while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line == "") continue; else if (line == $"[{fileName}]") currentSection = "Value"; else if (line[0] == '[') currentSection = line.Substring(1, line.Length - 2); - else - { + else { string variable = line.Substring(0, line.IndexOf('=')).Trim(); string value = line.Substring(line.IndexOf('=') + 1).Trim(); int query = findVariable(variable); - if (query == -1) - { + if (query == -1) { variables.Add(new INIVariable(name: variable)); - query = variables.Count-1; + query = variables.Count - 1; } - - switch (currentSection) - { + + switch (currentSection) { case "Value": updateValue(query, "Value", value); break; @@ -53,17 +46,14 @@ public INI(string fileName, System.IO.StreamReader reader) } } - public INI() - { + public INI() { this.fileName = "temp"; this.variables = new List(); } - public int findVariable(string name) - { + public int findVariable(string name) { int i = 0; - foreach (INIVariable var in variables) - { + foreach (INIVariable var in variables) { if (var.name == name) return i; i++; @@ -71,19 +61,15 @@ public int findVariable(string name) return -1; } - public bool isValid() - { + public bool isValid() { return true; } - public void loadTable(DataGridView table) - { + public void loadTable(DataGridView table) { table.Rows.Clear(); - foreach (INIVariable variable in variables) - { + foreach (INIVariable variable in variables) { int rowIndex = table.Rows.Add(variable.name, variable.type, variable.value, variable.comment); - if (variable.type == "boolean") - { + if (variable.type == "boolean") { DataGridViewCheckBoxCell cell = new DataGridViewCheckBoxCell(); cell.Value = variable.value; table.Rows[rowIndex].Cells[2] = cell; @@ -91,12 +77,9 @@ public void loadTable(DataGridView table) } } - public Boolean checkVariableNames(Boolean useMessagebox = true) - { - foreach (INIVariable var in variables) - { - if (tryToString(var.name) == "") - { + public Boolean checkVariableNames(Boolean useMessagebox = true) { + foreach (INIVariable var in variables) { + if (tryToString(var.name) == "") { if (useMessagebox) MessageBox.Show($"{this.fileName} contains a variable that does not have a valid name", "Invalid Type Or Value", MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; @@ -104,12 +87,9 @@ public Boolean checkVariableNames(Boolean useMessagebox = true) } return false; } - public Boolean checkVariableTypes(Boolean useMessagebox = true) - { - foreach (INIVariable var in variables) - { - if (tryToString(var.type) == "") - { + public Boolean checkVariableTypes(Boolean useMessagebox = true) { + foreach (INIVariable var in variables) { + if (tryToString(var.type) == "") { if (useMessagebox) MessageBox.Show($"{this.fileName} contains a variable \"{var.name}\" that does not have a type ", "Invalid Type", MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; @@ -118,12 +98,9 @@ public Boolean checkVariableTypes(Boolean useMessagebox = true) return false; } - public Boolean checkValues(Boolean useMessagebox = true) - { - foreach (INIVariable var in variables) - { - if ((tryToString(var.value).Trim() == "") && (tryToString(var.type).ToLower() != "string")) - { + public Boolean checkValues(Boolean useMessagebox = true) { + foreach (INIVariable var in variables) { + if (( tryToString(var.value).Trim() == "" ) && ( tryToString(var.type).ToLower() != "string" )) { if (useMessagebox) MessageBox.Show($"{this.fileName} contains a variable \"{var.name}\" that does not have a valid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; @@ -131,14 +108,11 @@ public Boolean checkValues(Boolean useMessagebox = true) } return false; } - - public Boolean checkVariableNameDuplicates(Boolean useMessagebox = true) - { + + public Boolean checkVariableNameDuplicates(Boolean useMessagebox = true) { List names = new List(); - foreach(INIVariable var in variables) - { - if(names.Contains(var.name)) - { + foreach (INIVariable var in variables) { + if (names.Contains(var.name)) { if (useMessagebox) MessageBox.Show($"There are two or more variables named {var.name} in {this.fileName}", "Duplicate Variable Names", MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; @@ -148,19 +122,15 @@ public Boolean checkVariableNameDuplicates(Boolean useMessagebox = true) return false; } - private String tryToString(object o) - { - if (o != null) - { + private String tryToString(object o) { + if (o != null) { return o.ToString(); } return ""; } - public void updateValue(int index, string valueType, string value) - { - switch (valueType) - { + public void updateValue(int index, string valueType, string value) { + switch (valueType) { case "Name": variables[index].name = value; break; @@ -168,8 +138,7 @@ public void updateValue(int index, string valueType, string value) variables[index].value = value; break; case "Type": - switch (value.ToLower()) - { + switch (value.ToLower()) { case "int": variables[index].type = "int"; break; @@ -179,7 +148,7 @@ public void updateValue(int index, string valueType, string value) case "boolean": variables[index].type = "boolean"; break; - default : + default: variables[index].type = "String"; break; } @@ -189,8 +158,7 @@ public void updateValue(int index, string valueType, string value) break; } } - public void updateVariable(int index, string name, string type, string value, string comment) - { + public void updateVariable(int index, string name, string type, string value, string comment) { variables[index].name = name; variables[index].type = type; variables[index].value = value; @@ -198,49 +166,39 @@ public void updateVariable(int index, string name, string type, string value, st } - public void addVariable(string name) - { + public void addVariable(string name) { this.variables.Add(new INIVariable(name: name)); } - public void addVariable(string name, string type, string value) - { + public void addVariable(string name, string type, string value) { this.variables.Add(new INIVariable(name: name, type: type, value: value)); } - public void clearVariables() - { + public void clearVariables() { this.variables.Clear(); } override - public string ToString() - { + public string ToString() { return this.fileName; } - public void removeAt(int index) - { + public void removeAt(int index) { variables.RemoveAt(index); } - public string toIni() - { + public string toIni() { string ini = $"[{fileName}]\n"; - foreach (INIVariable variable in variables) - { + foreach (INIVariable variable in variables) { ini += $"{variable.name} = {variable.value}\n"; } List others = new List() { "Type", "Comment" }; - foreach (string dataType in others) - { + foreach (string dataType in others) { ini += $"\n[{dataType}]\n"; - foreach (INIVariable variable in variables) - { - switch (dataType) - { + foreach (INIVariable variable in variables) { + switch (dataType) { case "Type": ini += $"{variable.name} = {variable.type}\n"; break; @@ -248,43 +206,35 @@ public string toIni() ini += $"{variable.name} = {variable.comment}\n"; break; } - + } } return ini; } - public string toJava() - { + public string toJava() { string fileContent = "package frc.robot.constants;\r\n\r\nimport org.frcteam3539.BulldogLibrary.INIConfiguration.BBConstants;\r\n\r\n"; - - fileContent+=$"public class {this.fileName.Replace(" ", "").Trim()} extends BBConstants "+"{"+"\r\n"; - fileContent += "\tpublic " + this.fileName+ "() {\r\n\t\tsuper(\"" + Properties.Settings.Default.INILocation + this.fileName+ ".ini\", true);\r\n\t\tsave();\r\n\t}\r\n\r\n"; + fileContent += $"public class {this.fileName.Replace(" ", "").Trim()} extends BBConstants " + "{" + "\r\n"; - foreach (INIVariable variable in variables) - { + fileContent += "\tpublic " + this.fileName + "() {\r\n\t\tsuper(\"" + Properties.Settings.Default.INILocation + this.fileName + ".ini\", true);\r\n\t\tsave();\r\n\t}\r\n\r\n"; + + foreach (INIVariable variable in variables) { string commentStr = ""; - if (variable.comment.Trim() != "") - { - commentStr = " // "+variable.comment.Trim(); + if (variable.comment.Trim() != "") { + commentStr = " // " + variable.comment.Trim(); } if (variable.type.ToLower() == "string") fileContent += $"\tpublic static {variable.type} {variable.name} = \"{variable.value}\";{commentStr}\r\n"; - else if(variable.type.ToLower() == "boolean") - { - if(variable.value.ToLower() == "true") - { + else if (variable.type.ToLower() == "boolean") { + if (variable.value.ToLower() == "true") { fileContent += $"\tpublic static {variable.type} {variable.name} = true;{commentStr}\r\n"; - } - else if (variable.value.ToLower() == "false") - { + } else if (variable.value.ToLower() == "false") { fileContent += $"\tpublic static {variable.type} {variable.name} = false;{commentStr}\r\n"; } - } - else + } else fileContent += $"\tpublic static {variable.type} {variable.name} = {variable.value};{commentStr}\r\n"; } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INIVariable.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INIVariable.cs index a2bbddc..cee236d 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INIVariable.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/Utilities/INIVariable.cs @@ -4,17 +4,14 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.Utilities -{ - class INIVariable - { +namespace MotionProfileMapper.Utilities { + class INIVariable { public string name { get; set; } public string type { get; set; } public string value { get; set; } public string comment { get; set; } - public INIVariable(string name = "", string type = "", string value = "", string comment = "") - { + public INIVariable(string name = "", string type = "", string value = "", string comment = "") { this.name = name; this.type = type; this.value = value; diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/CentripetalAccelerationConstraint.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/CentripetalAccelerationConstraint.cs index 3e68bf8..c737c07 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/CentripetalAccelerationConstraint.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/CentripetalAccelerationConstraint.cs @@ -4,22 +4,18 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class CentripetalAccelerationConstraint : TrajectoryConstraint - { +namespace MotionProfileMapper.VelocityGenerate { + public class CentripetalAccelerationConstraint : TrajectoryConstraint { private double maxCentripetalAcceleration; /** * @param maxCentripetalAcceleration the maximum centripetal acceleration */ - public CentripetalAccelerationConstraint(double maxCentripetalAcceleration) - { + public CentripetalAccelerationConstraint(double maxCentripetalAcceleration) { this.maxCentripetalAcceleration = maxCentripetalAcceleration; } - override public double getMaxVelocity(PState state) - { + override public double getMaxVelocity(PState state) { // let A be the centripetal acceleration // let V be the max velocity // let C be the curvature of the path @@ -32,21 +28,18 @@ override public double getMaxVelocity(PState state) // needed. // Special case when following a line, centripetal acceleration is 0 so don't constrain velocity - if (state.getRadius() == 0.0) - { + if (state.getRadius() == 0.0) { return Double.PositiveInfinity; } - if (state.getRadius() == Double.PositiveInfinity) - { + if (state.getRadius() == Double.PositiveInfinity) { return Double.PositiveInfinity; } - if (double.IsNaN(state.getRadius())) - { + if (double.IsNaN(state.getRadius())) { return Double.PositiveInfinity; } - return Math.Sqrt((maxCentripetalAcceleration * state.getRadius())); + return Math.Sqrt(( maxCentripetalAcceleration * state.getRadius() )); } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/ConstrainedPathState.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/ConstrainedPathState.cs index 7918195..61f7605 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/ConstrainedPathState.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/ConstrainedPathState.cs @@ -6,11 +6,9 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ +namespace MotionProfileMapper.VelocityGenerate { - class ConstrainedPathState - { + class ConstrainedPathState { public PState pathState; public double length; public double startingVelocity; @@ -18,8 +16,7 @@ class ConstrainedPathState public double acceleration; public ProfilePath path; - public ConstrainedPathState(ProfilePath path, PState pathState, double length, double startingVelocity, double endingVelocity, double acceleration) - { + public ConstrainedPathState(ProfilePath path, PState pathState, double length, double startingVelocity, double endingVelocity, double acceleration) { this.path = path; this.pathState = pathState; this.length = length; @@ -28,32 +25,25 @@ public ConstrainedPathState(ProfilePath path, PState pathState, double length, d this.acceleration = acceleration; } - public double getDuration() - { - if (MathUtils.epsilonEquals(acceleration, 0.0)) - { + public double getDuration() { + if (MathUtils.epsilonEquals(acceleration, 0.0)) { return length / startingVelocity; } - if (MathUtils.epsilonEquals(endingVelocity, 0.0)) - { - return (startingVelocity / -acceleration); + if (MathUtils.epsilonEquals(endingVelocity, 0.0)) { + return ( startingVelocity / -acceleration ); } double[] roots = MathUtils.quadratic(0.5 * acceleration, startingVelocity, -length); - if (acceleration > 0.0) - { + if (acceleration > 0.0) { return Math.Max(roots[0], roots[1]); - } - else - { + } else { return Math.Min(roots[0], roots[1]); } } - public State calculate(double time) - { + public State calculate(double time) { time = MathUtils.clamp(time, 0.0, getDuration()); double distance = 0.5 * acceleration * Math.Pow(time, 2.0) + startingVelocity * time + pathState.getDistance(); @@ -67,41 +57,34 @@ public State calculate(double time) } - public class State - { + public class State { private PState pathState; private double velocity; private double acceleration; private double time; - public State(PState pathState, double velocity, double acceleration) - { + public State(PState pathState, double velocity, double acceleration) { this.pathState = pathState; this.velocity = velocity; this.acceleration = acceleration; } - public void setTime(double time) - { + public void setTime(double time) { this.time = time; } - public PState getPathState() - { + public PState getPathState() { return pathState; } - public double getVelocity() - { + public double getVelocity() { return velocity; } - public double getAcceleration() - { + public double getAcceleration() { return acceleration; } - public double getTime() - { + public double getTime() { return time; } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtil.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtil.cs index cafdb0e..3db182a 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtil.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtil.cs @@ -4,10 +4,8 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - class MathUtil - { +namespace MotionProfileMapper.VelocityGenerate { + class MathUtil { /** * Returns value clamped between low and high boundaries. @@ -17,8 +15,7 @@ class MathUtil * @param high The higher boundary to which to clamp value. * @return The clamped value. */ - public static int clamp(int value, int low, int high) - { + public static int clamp(int value, int low, int high) { return Math.Max(low, Math.Min(value, high)); } @@ -30,8 +27,7 @@ public static int clamp(int value, int low, int high) * @param high The higher boundary to which to clamp value. * @return The clamped value. */ - public static double clamp(double value, double low, double high) - { + public static double clamp(double value, double low, double high) { return Math.Max(low, Math.Min(value, high)); } @@ -44,19 +40,15 @@ public static double clamp(double value, double low, double high) * @param maxMagnitude The maximum magnitude of the input. Can be infinite. * @return The value after the deadband is applied. */ - public static double applyDeadband(double value, double deadband, double maxMagnitude) - { - if (Math.Abs(value) > deadband) - { - if (maxMagnitude / deadband > 1.0e12) - { + public static double applyDeadband(double value, double deadband, double maxMagnitude) { + if (Math.Abs(value) > deadband) { + if (maxMagnitude / deadband > 1.0e12) { // If max magnitude is sufficiently large, the implementation encounters // roundoff error. Implementing the limiting behavior directly avoids // the problem. return value > 0.0 ? value - deadband : value + deadband; } - if (value > 0.0) - { + if (value > 0.0) { // Map deadband to 0 and map max to max. // // y - y₁ = m(x - x₁) @@ -72,10 +64,8 @@ public static double applyDeadband(double value, double deadband, double maxMagn // y = (max - 0)/(max - deadband) (x - deadband) + 0 // y = max/(max - deadband) (x - deadband) // y = max (x - deadband)/(max - deadband) - return maxMagnitude * (value - deadband) / (maxMagnitude - deadband); - } - else - { + return maxMagnitude * ( value - deadband ) / ( maxMagnitude - deadband ); + } else { // Map -deadband to 0 and map -max to -max. // // y - y₁ = m(x - x₁) @@ -91,11 +81,9 @@ public static double applyDeadband(double value, double deadband, double maxMagn // y = (-max - 0)/(-max + deadband) (x + deadband) + 0 // y = max/(max - deadband) (x + deadband) // y = max (x + deadband)/(max - deadband) - return maxMagnitude * (value + deadband) / (maxMagnitude - deadband); + return maxMagnitude * ( value + deadband ) / ( maxMagnitude - deadband ); } - } - else - { + } else { return 0.0; } } @@ -108,8 +96,7 @@ public static double applyDeadband(double value, double deadband, double maxMagn * @param deadband Range around zero. * @return The value after the deadband is applied. */ - public static double applyDeadband(double value, double deadband) - { + public static double applyDeadband(double value, double deadband) { return applyDeadband(value, deadband, 1); } @@ -121,16 +108,15 @@ public static double applyDeadband(double value, double deadband) * @param maximumInput The maximum value expected from the input. * @return The wrapped value. */ - public static double inputModulus(double input, double minimumInput, double maximumInput) - { + public static double inputModulus(double input, double minimumInput, double maximumInput) { double modulus = maximumInput - minimumInput; // Wrap input if it's above the maximum input - int numMax = (int)((input - minimumInput) / modulus); + int numMax = (int) ( ( input - minimumInput ) / modulus ); input -= numMax * modulus; // Wrap input if it's below the minimum input - int numMin = (int)((input - maximumInput) / modulus); + int numMin = (int) ( ( input - maximumInput ) / modulus ); input -= numMin * modulus; return input; @@ -142,8 +128,7 @@ public static double inputModulus(double input, double minimumInput, double maxi * @param angleRadians Angle to wrap in radians. * @return The wrapped angle. */ - public static double angleModulus(double angleRadians) - { + public static double angleModulus(double angleRadians) { return inputModulus(angleRadians, -Math.PI, Math.PI); } @@ -155,9 +140,8 @@ public static double angleModulus(double angleRadians) * @param t How far between the two values to interpolate. This is clamped to [0, 1]. * @return The interpolated value. */ - public static double interpolate(double startValue, double endValue, double t) - { - return startValue + (endValue - startValue) * MathUtil.clamp(t, 0, 1); + public static double interpolate(double startValue, double endValue, double t) { + return startValue + ( endValue - startValue ) * MathUtil.clamp(t, 0, 1); } } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtils.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtils.cs index 92a9ffe..54a7a66 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtils.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MathUtils.cs @@ -4,10 +4,8 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - class MathUtils - { +namespace MotionProfileMapper.VelocityGenerate { + class MathUtils { /** * Default epsilon for {@link #epsilonEquals(double, double)} * @@ -27,10 +25,8 @@ private MathUtils() { } * * @since 0.2 */ - public static double clamp(double value, double min, double max) - { - if (min > max) - { + public static double clamp(double value, double min, double max) { + if (min > max) { throw new ArgumentException("min must not be greater than max"); } @@ -47,8 +43,7 @@ public static double clamp(double value, double min, double max) * * @since 0.1 */ - public static bool epsilonEquals(double a, double b) - { + public static bool epsilonEquals(double a, double b) { return epsilonEquals(a, b, EPSILON); } @@ -64,8 +59,7 @@ public static bool epsilonEquals(double a, double b) * * @since 0.1 */ - public static bool epsilonEquals(double a, double b, double epsilon) - { + public static bool epsilonEquals(double a, double b, double epsilon) { return Math.Abs(a - b) < epsilon; } @@ -80,8 +74,7 @@ public static bool epsilonEquals(double a, double b, double epsilon) * * @since 0.1 */ - public static bool isInRange(double lowerBound, double upperBound, double value) - { + public static bool isInRange(double lowerBound, double upperBound, double value) { return lowerBound <= value && value <= upperBound; } @@ -93,11 +86,9 @@ public static bool isInRange(double lowerBound, double upperBound, double value) * @param c the c coefficient * @return the real roots of the equation */ - public static double[] quadratic(double a, double b, double c) - { + public static double[] quadratic(double a, double b, double c) { double sqrt = Math.Sqrt(b * b - 4 * a * c); - if (Double.IsNaN(sqrt)) - { + if (Double.IsNaN(sqrt)) { // No roots return new double[0]; } @@ -108,25 +99,19 @@ public static double[] quadratic(double a, double b, double c) }; } - public static double lerp(double start, double end, double t) - { - return start + (end - start) * t; + public static double lerp(double start, double end, double t) { + return start + ( end - start ) * t; } - public static double inverseLerp(double start, double end, double query) - { + public static double inverseLerp(double start, double end, double query) { return inverseLerp(start, end, query, true); } - public static double inverseLerp(double start, double end, double query, bool shouldClamp) - { - double t = (query - start) / (end - start); - if (shouldClamp) - { + public static double inverseLerp(double start, double end, double query, bool shouldClamp) { + double t = ( query - start ) / ( end - start ); + if (shouldClamp) { return clamp(t, 0.0, 1.0); - } - else - { + } else { return t; } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxAccelerationConstraint.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxAccelerationConstraint.cs index a8bc9b1..755dbd3 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxAccelerationConstraint.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxAccelerationConstraint.cs @@ -4,36 +4,28 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ +namespace MotionProfileMapper.VelocityGenerate { /** * A constraint that limits the acceleration. */ - public class MaxAccelerationConstraint : TrajectoryConstraint - { + public class MaxAccelerationConstraint : TrajectoryConstraint { private double maxAcceleration; private double maxDeceleration; - public MaxAccelerationConstraint(double maxAbsAcceleration) - { + public MaxAccelerationConstraint(double maxAbsAcceleration) { this.maxAcceleration = maxAbsAcceleration; this.maxDeceleration = maxAbsAcceleration; } - - public MaxAccelerationConstraint(double maxAcceleration, double maxDeceleration) - { + public MaxAccelerationConstraint(double maxAcceleration, double maxDeceleration) { this.maxAcceleration = maxAcceleration; this.maxDeceleration = maxDeceleration; } - - override public double getMaxAcceleration(PState state, double velocity) - { + override public double getMaxAcceleration(PState state, double velocity) { return maxAcceleration; } - override public double getMaxDeceleration(PState state, double velocity) - { + override public double getMaxDeceleration(PState state, double velocity) { return maxDeceleration; } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxVelocityContraint.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxVelocityContraint.cs index 500f24e..0565d26 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxVelocityContraint.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/MaxVelocityContraint.cs @@ -4,20 +4,16 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class MaxVelocityConstraint : TrajectoryConstraint - { - private double maxVelocity; +namespace MotionProfileMapper.VelocityGenerate { + public class MaxVelocityConstraint : TrajectoryConstraint { + private double maxVelocity; - public MaxVelocityConstraint(double maxVelocity) - { - this.maxVelocity = maxVelocity; - } + public MaxVelocityConstraint(double maxVelocity) { + this.maxVelocity = maxVelocity; + } - public override double getMaxVelocity(PState state) - { - return maxVelocity; + public override double getMaxVelocity(PState state) { + return maxVelocity; + } } } -} diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Path.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Path.cs index bd42da5..23f6c6b 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Path.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Path.cs @@ -4,50 +4,41 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - class Path - { +namespace MotionProfileMapper.VelocityGenerate { + class Path { } - public class PState - { + public class PState { private double distance; private Pose2d pose; private Rotation2d heading; private double radius; - public PState(double distance, Pose2d pose, Rotation2d heading, double radius) - { + public PState(double distance, Pose2d pose, Rotation2d heading, double radius) { this.distance = distance; this.pose = pose; this.heading = heading; this.radius = radius; } - public double getDistance() - { + public double getDistance() { return distance; } - public Pose2d getPose2d() - { + public Pose2d getPose2d() { return pose; } - public Rotation2d getHeading() - { + public Rotation2d getHeading() { return heading; } - public double getRadius() - { + public double getRadius() { return radius; } - public String toString() - { + public String toString() { string format = "0.###"; return "(distance," + getDistance().ToString(format) + ",pose," + getPose2d() + diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Pose2d.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Pose2d.cs index 713fa3a..1002def 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Pose2d.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Pose2d.cs @@ -4,16 +4,13 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class Pose2d - { +namespace MotionProfileMapper.VelocityGenerate { + public class Pose2d { private Translation2d m_translation; private Rotation2d m_rotation; /** Constructs a pose at the origin facing toward the positive X axis. */ - public Pose2d() - { + public Pose2d() { m_translation = new Translation2d(); m_rotation = new Rotation2d(); } @@ -24,8 +21,7 @@ public Pose2d() * @param translation The translational component of the pose. * @param rotation The rotational component of the pose. */ - public Pose2d(Translation2d translation, Rotation2d rotation) - { + public Pose2d(Translation2d translation, Rotation2d rotation) { m_translation = translation; m_rotation = rotation; } @@ -37,13 +33,11 @@ public Pose2d(Translation2d translation, Rotation2d rotation) * @param y The y component of the translational component of the pose. * @param rotation The rotational component of the pose. */ - public Pose2d(double x, double y, Rotation2d rotation) - { + public Pose2d(double x, double y, Rotation2d rotation) { m_translation = new Translation2d(x, y); m_rotation = rotation; } - public Translation2d getTranslation() - { + public Translation2d getTranslation() { return m_translation; } @@ -52,8 +46,7 @@ public Translation2d getTranslation() * * @return The x component of the pose's translation. */ - public double getX() - { + public double getX() { return m_translation.getX(); } @@ -62,8 +55,7 @@ public double getX() * * @return The y component of the pose's translation. */ - public double getY() - { + public double getY() { return m_translation.getY(); } @@ -72,8 +64,7 @@ public double getY() * * @return The rotational component of the pose. */ - public Rotation2d getRotation() - { + public Rotation2d getRotation() { return m_rotation; } @@ -83,8 +74,7 @@ public Rotation2d getRotation() * @param scalar The scalar. * @return The new scaled Pose2d. */ - public Pose2d times(double scalar) - { + public Pose2d times(double scalar) { return new Pose2d(m_translation.times(scalar), m_rotation.times(scalar)); } @@ -94,14 +84,12 @@ public Pose2d times(double scalar) * @param scalar The scalar. * @return The new scaled Pose2d. */ - public Pose2d div(double scalar) - { + public Pose2d div(double scalar) { return times(1.0 / scalar); } - public String toString() - { + public String toString() { return String.Format("Pose2d({0}, {0})", m_translation, m_rotation); } @@ -112,18 +100,15 @@ public String toString() * @return Whether the two objects are equal or not. */ - public bool equals(Object obj) - { - if (obj.GetType() == typeof(Pose2d)) - { - return ((Pose2d)obj).m_translation.equals(m_translation) - && ((Pose2d)obj).m_rotation.equals(m_rotation); + public bool equals(Object obj) { + if (obj.GetType() == typeof(Pose2d)) { + return ( (Pose2d) obj ).m_translation.equals(m_translation) + && ( (Pose2d) obj ).m_rotation.equals(m_rotation); } return false; } - public int hashCode() - { + public int hashCode() { int hash = 17; hash = hash * 31 + m_translation.GetHashCode(); hash = hash * 31 + m_rotation.GetHashCode(); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Rotation2d.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Rotation2d.cs index 580b7a8..71c71d6 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Rotation2d.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Rotation2d.cs @@ -4,17 +4,14 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class Rotation2d - { +namespace MotionProfileMapper.VelocityGenerate { + public class Rotation2d { private double m_value; private double m_cos; private double m_sin; /** Constructs a Rotation2d with a default angle of 0 degrees. */ - public Rotation2d() - { + public Rotation2d() { m_value = 0.0; m_cos = 1.0; m_sin = 0.0; @@ -25,8 +22,7 @@ public Rotation2d() * * @param value The value of the angle in radians. */ - public Rotation2d(double value) - { + public Rotation2d(double value) { m_value = value; m_cos = Math.Cos(value); m_sin = Math.Sin(value); @@ -38,16 +34,12 @@ public Rotation2d(double value) * @param x The x component or cosine of the rotation. * @param y The y component or sine of the rotation. */ - public Rotation2d(double x, double y) - { + public Rotation2d(double x, double y) { double magnitude = hypo(x, y); - if (magnitude > 1e-6) - { + if (magnitude > 1e-6) { m_sin = y / magnitude; m_cos = x / magnitude; - } - else - { + } else { m_sin = 0.0; m_cos = 1.0; } @@ -60,8 +52,7 @@ public Rotation2d(double x, double y) * @param radians The value of the angle in radians. * @return The rotation object with the desired angle value. */ - public static Rotation2d fromRadians(double radians) - { + public static Rotation2d fromRadians(double radians) { return new Rotation2d(radians); } @@ -71,8 +62,7 @@ public static Rotation2d fromRadians(double radians) * @param degrees The value of the angle in degrees. * @return The rotation object with the desired angle value. */ - public static Rotation2d fromDegrees(double degrees) - { + public static Rotation2d fromDegrees(double degrees) { return new Rotation2d(Units.degreesToRadians(degrees)); } @@ -82,8 +72,7 @@ public static Rotation2d fromDegrees(double degrees) * @param rotations The value of the angle in rotations. * @return The rotation object with the desired angle value. */ - public static Rotation2d fromRotations(double rotations) - { + public static Rotation2d fromRotations(double rotations) { return new Rotation2d(Units.rotationsToRadians(rotations)); } @@ -96,8 +85,7 @@ public static Rotation2d fromRotations(double rotations) * @param other The rotation to add. * @return The sum of the two rotations. */ - public Rotation2d plus(Rotation2d other) - { + public Rotation2d plus(Rotation2d other) { return rotateBy(other); } @@ -110,8 +98,7 @@ public Rotation2d plus(Rotation2d other) * @param other The rotation to subtract. * @return The difference between the two rotations. */ - public Rotation2d minus(Rotation2d other) - { + public Rotation2d minus(Rotation2d other) { return rotateBy(other.unaryMinus()); } @@ -121,8 +108,7 @@ public Rotation2d minus(Rotation2d other) * * @return The inverse of the current rotation. */ - public Rotation2d unaryMinus() - { + public Rotation2d unaryMinus() { return new Rotation2d(-m_value); } @@ -132,8 +118,7 @@ public Rotation2d unaryMinus() * @param scalar The scalar. * @return The new scaled Rotation2d. */ - public Rotation2d times(double scalar) - { + public Rotation2d times(double scalar) { return new Rotation2d(m_value * scalar); } @@ -143,8 +128,7 @@ public Rotation2d times(double scalar) * @param scalar The scalar. * @return The new scaled Rotation2d. */ - public Rotation2d div(double scalar) - { + public Rotation2d div(double scalar) { return times(1.0 / scalar); } @@ -162,8 +146,7 @@ public Rotation2d div(double scalar) * @param other The rotation to rotate by. * @return The new rotated Rotation2d. */ - public Rotation2d rotateBy(Rotation2d other) - { + public Rotation2d rotateBy(Rotation2d other) { return new Rotation2d( m_cos * other.m_cos - m_sin * other.m_sin, m_cos * other.m_sin + m_sin * other.m_cos); } @@ -174,8 +157,7 @@ public Rotation2d rotateBy(Rotation2d other) * @return The radian value of the Rotation2d. * @see edu.wpi.first.math.MathUtil#angleModulus(double) to constrain the angle within (-pi, pi] */ - public double getRadians() - { + public double getRadians() { return m_value; } @@ -186,8 +168,7 @@ public double getRadians() * @see edu.wpi.first.math.MathUtil#inputModulus(double, double, double) to constrain the angle * within (-180, 180] */ - public double getDegrees() - { + public double getDegrees() { return Units.radiansToDegrees(m_value); } @@ -196,8 +177,7 @@ public double getDegrees() * * @return The number of rotations of the Rotation2d. */ - public double getRotations() - { + public double getRotations() { return Units.radiansToRotations(m_value); } @@ -206,8 +186,7 @@ public double getRotations() * * @return The cosine of the Rotation2d. */ - public double getCos() - { + public double getCos() { return m_cos; } @@ -216,8 +195,7 @@ public double getCos() * * @return The sine of the Rotation2d. */ - public double getSin() - { + public double getSin() { return m_sin; } @@ -226,12 +204,10 @@ public double getSin() * * @return The tangent of the Rotation2d. */ - public double getTan() - { + public double getTan() { return m_sin / m_cos; } - public String toString() - { + public String toString() { return String.Format("Rotation2d(Rads: {0:0.00}, Deg: {0:0.00})", m_value, Units.radiansToDegrees(m_value)); } @@ -241,28 +217,23 @@ public String toString() * @param obj The other object. * @return Whether the two objects are equal or not. */ - public bool equals(Object obj) - { - if (obj.GetType() == typeof(Rotation2d)) - { - var other = (Rotation2d)obj; + public bool equals(Object obj) { + if (obj.GetType() == typeof(Rotation2d)) { + var other = (Rotation2d) obj; return hypo(m_cos - other.m_cos, m_sin - other.m_sin) < 1E-9; } return false; } - public double hypo(double x, double y) - { + public double hypo(double x, double y) { return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); } - public int hashCode() - { + public int hashCode() { return m_value.GetHashCode(); } - public Rotation2d interpolate(Rotation2d endValue, double t) - { + public Rotation2d interpolate(Rotation2d endValue, double t) { return plus(endValue.minus(this).times(MathUtil.clamp(t, 0, 1))); } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/TrajectoryConstraint.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/TrajectoryConstraint.cs index 69a1650..9ec110b 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/TrajectoryConstraint.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/TrajectoryConstraint.cs @@ -4,18 +4,15 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public abstract class TrajectoryConstraint - { +namespace MotionProfileMapper.VelocityGenerate { + public abstract class TrajectoryConstraint { /** * Gets the maximum velocity this constraint allows for a path state. * * @param state the path state. * @return the maximum velocity. */ - public virtual double getMaxVelocity(PState state) - { + public virtual double getMaxVelocity(PState state) { return Double.PositiveInfinity; } @@ -26,8 +23,7 @@ public virtual double getMaxVelocity(PState state) * @param velocity the velocity. * @return the maximum acceleration. */ - public virtual double getMaxAcceleration(PState state, double velocity) - { + public virtual double getMaxAcceleration(PState state, double velocity) { return Double.PositiveInfinity; } @@ -38,8 +34,7 @@ public virtual double getMaxAcceleration(PState state, double velocity) * @param velocity the velocity. * @return the maximum deceleration.s */ - public virtual double getMaxDeceleration(PState state, double velocity) - { + public virtual double getMaxDeceleration(PState state, double velocity) { return getMaxAcceleration(state, velocity); } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Translation2d.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Translation2d.cs index d0f81f6..909960c 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Translation2d.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Translation2d.cs @@ -4,16 +4,13 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class Translation2d - { +namespace MotionProfileMapper.VelocityGenerate { + public class Translation2d { private double m_x; private double m_y; /** Constructs a Translation2d with X and Y components equal to zero. */ - public Translation2d() - { + public Translation2d() { m_x = 0.0; m_y = 0.0; } @@ -25,8 +22,7 @@ public Translation2d() * @param y The y component of the translation. */ - public Translation2d(double x, double y) - { + public Translation2d(double x, double y) { m_x = x; m_y = y; } @@ -38,8 +34,7 @@ public Translation2d(double x, double y) * @param distance The distance from the origin to the end of the translation. * @param angle The angle between the x-axis and the translation vector. */ - public Translation2d(double distance, Rotation2d angle) - { + public Translation2d(double distance, Rotation2d angle) { m_x = distance * angle.getCos(); m_y = distance * angle.getSin(); } @@ -52,8 +47,7 @@ public Translation2d(double distance, Rotation2d angle) * @param other The translation to compute the distance to. * @return The distance between the two translations. */ - public double getDistance(Translation2d other) - { + public double getDistance(Translation2d other) { return hypo(other.m_x - m_x, other.m_y - m_y); } @@ -62,8 +56,7 @@ public double getDistance(Translation2d other) * * @return The X component of the translation. */ - public double getX() - { + public double getX() { return m_x; } @@ -72,8 +65,7 @@ public double getX() * * @return The Y component of the translation. */ - public double getY() - { + public double getY() { return m_y; } @@ -82,8 +74,7 @@ public double getY() * * @return The norm of the translation. */ - public double getNorm() - { + public double getNorm() { return hypo(m_x, m_y); } @@ -92,8 +83,7 @@ public double getNorm() * * @return The angle of the translation */ - public Rotation2d getAngle() - { + public Rotation2d getAngle() { return new Rotation2d(m_x, m_y); } @@ -114,8 +104,7 @@ public Rotation2d getAngle() * @param other The rotation to rotate the translation by. * @return The new rotated translation. */ - public Translation2d rotateBy(Rotation2d other) - { + public Translation2d rotateBy(Rotation2d other) { return new Translation2d( m_x * other.getCos() - m_y * other.getSin(), m_x * other.getSin() + m_y * other.getCos()); } @@ -128,8 +117,7 @@ public Translation2d rotateBy(Rotation2d other) * @param other The translation to add. * @return The sum of the translations. */ - public Translation2d plus(Translation2d other) - { + public Translation2d plus(Translation2d other) { return new Translation2d(m_x + other.m_x, m_y + other.m_y); } @@ -141,8 +129,7 @@ public Translation2d plus(Translation2d other) * @param other The translation to subtract. * @return The difference between the two translations. */ - public Translation2d minus(Translation2d other) - { + public Translation2d minus(Translation2d other) { return new Translation2d(m_x - other.m_x, m_y - other.m_y); } @@ -152,8 +139,7 @@ public Translation2d minus(Translation2d other) * * @return The inverse of the current translation. */ - public Translation2d unaryMinus() - { + public Translation2d unaryMinus() { return new Translation2d(-m_x, -m_y); } @@ -165,8 +151,7 @@ public Translation2d unaryMinus() * @param scalar The scalar to multiply by. * @return The scaled translation. */ - public Translation2d times(double scalar) - { + public Translation2d times(double scalar) { return new Translation2d(m_x * scalar, m_y * scalar); } @@ -178,8 +163,7 @@ public Translation2d times(double scalar) * @param scalar The scalar to multiply by. * @return The reference to the new mutated object. */ - public Translation2d div(double scalar) - { + public Translation2d div(double scalar) { return new Translation2d(m_x / scalar, m_y / scalar); } @@ -196,8 +180,7 @@ public Translation2d div(double scalar) return Collections.min(translations, Comparator.comparing(this::getDistance)); }*/ - public String toString() - { + public String toString() { return String.Format("Translation2d(X: {0:0.00}, Y: {0:0.00})", m_x, m_y); } @@ -207,30 +190,25 @@ public String toString() * @param obj The other object. * @return Whether the two objects are equal or not. */ - public bool equals(Object obj) - { - if (obj.GetType() == typeof(Translation2d)) - { - return Math.Abs(((Translation2d)obj).m_x - m_x) < 1E-9 - && Math.Abs(((Translation2d)obj).m_y - m_y) < 1E-9; + public bool equals(Object obj) { + if (obj.GetType() == typeof(Translation2d)) { + return Math.Abs(( (Translation2d) obj ).m_x - m_x) < 1E-9 + && Math.Abs(( (Translation2d) obj ).m_y - m_y) < 1E-9; } return false; } - public double hypo(double x, double y) - { + public double hypo(double x, double y) { return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); } - public int hashCode() - { + public int hashCode() { int hash = 17; hash = hash * 31 + m_x.GetHashCode(); hash = hash * 31 + m_y.GetHashCode(); return hash; } - public Translation2d interpolate(Translation2d endValue, double t) - { + public Translation2d interpolate(Translation2d endValue, double t) { return new Translation2d( MathUtil.interpolate(this.getX(), endValue.getX(), t), MathUtil.interpolate(this.getY(), endValue.getY(), t)); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Units.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Units.cs index 14e662e..63d0e2b 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Units.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/Units.cs @@ -4,190 +4,172 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - class Units - { - private static double kInchesPerFoot = 12.0; - private static double kMetersPerInch = 0.0254; - private static double kSecondsPerMinute = 60; - private static double kMillisecondsPerSecond = 1000; - private static double kKilogramsPerLb = 0.453592; - - /** - * Converts given meters to feet. - * - * @param meters The meters to convert to feet. - * @return Feet converted from meters. - */ - public static double metersToFeet(double meters) - { - return metersToInches(meters) / kInchesPerFoot; - } - - /** - * Converts given feet to meters. - * - * @param feet The feet to convert to meters. - * @return Meters converted from feet. - */ - public static double feetToMeters(double feet) - { - return inchesToMeters(feet * kInchesPerFoot); - } - - /** - * Converts given meters to inches. - * - * @param meters The meters to convert to inches. - * @return Inches converted from meters. - */ - public static double metersToInches(double meters) - { - return meters / kMetersPerInch; - } - - /** - * Converts given inches to meters. - * - * @param inches The inches to convert to meters. - * @return Meters converted from inches. - */ - public static double inchesToMeters(double inches) - { - return inches * kMetersPerInch; - } - - /** - * Converts given degrees to radians. - * - * @param degrees The degrees to convert to radians. - * @return Radians converted from degrees. - */ - public static double degreesToRadians(double degrees) - { - return (degrees * Math.PI) / 180.0; - } - - /** - * Converts given radians to degrees. - * - * @param radians The radians to convert to degrees. - * @return Degrees converted from radians. - */ - public static double radiansToDegrees(double radians) - { - return (radians*180)/Math.PI; - } - - /** - * Converts given radians to rotations. - * - * @param radians The radians to convert. - * @return rotations Converted from radians. - */ - public static double radiansToRotations(double radians) - { - return radians / (Math.PI * 2); - } - - /** - * Converts given degrees to rotations. - * - * @param degrees The degrees to convert. - * @return rotations Converted from degrees. - */ - public static double degreesToRotations(double degrees) - { - return degrees / 360; - } - - /** - * Converts given rotations to degrees. - * - * @param rotations The rotations to convert. - * @return degrees Converted from rotations. - */ - public static double rotationsToDegrees(double rotations) - { - return rotations * 360; - } - - /** - * Converts given rotations to radians. - * - * @param rotations The rotations to convert. - * @return radians Converted from rotations. - */ - public static double rotationsToRadians(double rotations) - { - return rotations * 2 * Math.PI; - } - - /** - * Converts rotations per minute to radians per second. - * - * @param rpm The rotations per minute to convert to radians per second. - * @return Radians per second converted from rotations per minute. - */ - public static double rotationsPerMinuteToRadiansPerSecond(double rpm) - { - return rpm * Math.PI / (kSecondsPerMinute / 2); - } - - /** - * Converts radians per second to rotations per minute. - * - * @param radiansPerSecond The radians per second to convert to from rotations per minute. - * @return Rotations per minute converted from radians per second. - */ - public static double radiansPerSecondToRotationsPerMinute(double radiansPerSecond) - { - return radiansPerSecond * (kSecondsPerMinute / 2) / Math.PI; - } - - /** - * Converts given milliseconds to seconds. - * - * @param milliseconds The milliseconds to convert to seconds. - * @return Seconds converted from milliseconds. - */ - public static double millisecondsToSeconds(double milliseconds) - { - return milliseconds / kMillisecondsPerSecond; - } - - /** - * Converts given seconds to milliseconds. - * - * @param seconds The seconds to convert to milliseconds. - * @return Milliseconds converted from seconds. - */ - public static double secondsToMilliseconds(double seconds) - { - return seconds * kMillisecondsPerSecond; - } - - /** - * Converts kilograms into lbs (pound-mass). - * - * @param kilograms The kilograms to convert to lbs (pound-mass). - * @return Lbs (pound-mass) converted from kilograms. - */ - public static double kilogramsToLbs(double kilograms) - { - return kilograms / kKilogramsPerLb; - } - - /** - * Converts lbs (pound-mass) into kilograms. - * - * @param lbs The lbs (pound-mass) to convert to kilograms. - * @return Kilograms converted from lbs (pound-mass). - */ - public static double lbsToKilograms(double lbs) - { - return lbs * kKilogramsPerLb; - } +namespace MotionProfileMapper.VelocityGenerate { + class Units { + private static double kInchesPerFoot = 12.0; + private static double kMetersPerInch = 0.0254; + private static double kSecondsPerMinute = 60; + private static double kMillisecondsPerSecond = 1000; + private static double kKilogramsPerLb = 0.453592; + + /** + * Converts given meters to feet. + * + * @param meters The meters to convert to feet. + * @return Feet converted from meters. + */ + public static double metersToFeet(double meters) { + return metersToInches(meters) / kInchesPerFoot; } + + /** + * Converts given feet to meters. + * + * @param feet The feet to convert to meters. + * @return Meters converted from feet. + */ + public static double feetToMeters(double feet) { + return inchesToMeters(feet * kInchesPerFoot); + } + + /** + * Converts given meters to inches. + * + * @param meters The meters to convert to inches. + * @return Inches converted from meters. + */ + public static double metersToInches(double meters) { + return meters / kMetersPerInch; + } + + /** + * Converts given inches to meters. + * + * @param inches The inches to convert to meters. + * @return Meters converted from inches. + */ + public static double inchesToMeters(double inches) { + return inches * kMetersPerInch; + } + + /** + * Converts given degrees to radians. + * + * @param degrees The degrees to convert to radians. + * @return Radians converted from degrees. + */ + public static double degreesToRadians(double degrees) { + return ( degrees * Math.PI ) / 180.0; + } + + /** + * Converts given radians to degrees. + * + * @param radians The radians to convert to degrees. + * @return Degrees converted from radians. + */ + public static double radiansToDegrees(double radians) { + return ( radians * 180 ) / Math.PI; + } + + /** + * Converts given radians to rotations. + * + * @param radians The radians to convert. + * @return rotations Converted from radians. + */ + public static double radiansToRotations(double radians) { + return radians / ( Math.PI * 2 ); + } + + /** + * Converts given degrees to rotations. + * + * @param degrees The degrees to convert. + * @return rotations Converted from degrees. + */ + public static double degreesToRotations(double degrees) { + return degrees / 360; + } + + /** + * Converts given rotations to degrees. + * + * @param rotations The rotations to convert. + * @return degrees Converted from rotations. + */ + public static double rotationsToDegrees(double rotations) { + return rotations * 360; + } + + /** + * Converts given rotations to radians. + * + * @param rotations The rotations to convert. + * @return radians Converted from rotations. + */ + public static double rotationsToRadians(double rotations) { + return rotations * 2 * Math.PI; + } + + /** + * Converts rotations per minute to radians per second. + * + * @param rpm The rotations per minute to convert to radians per second. + * @return Radians per second converted from rotations per minute. + */ + public static double rotationsPerMinuteToRadiansPerSecond(double rpm) { + return rpm * Math.PI / ( kSecondsPerMinute / 2 ); + } + + /** + * Converts radians per second to rotations per minute. + * + * @param radiansPerSecond The radians per second to convert to from rotations per minute. + * @return Rotations per minute converted from radians per second. + */ + public static double radiansPerSecondToRotationsPerMinute(double radiansPerSecond) { + return radiansPerSecond * ( kSecondsPerMinute / 2 ) / Math.PI; + } + + /** + * Converts given milliseconds to seconds. + * + * @param milliseconds The milliseconds to convert to seconds. + * @return Seconds converted from milliseconds. + */ + public static double millisecondsToSeconds(double milliseconds) { + return milliseconds / kMillisecondsPerSecond; + } + + /** + * Converts given seconds to milliseconds. + * + * @param seconds The seconds to convert to milliseconds. + * @return Milliseconds converted from seconds. + */ + public static double secondsToMilliseconds(double seconds) { + return seconds * kMillisecondsPerSecond; + } + + /** + * Converts kilograms into lbs (pound-mass). + * + * @param kilograms The kilograms to convert to lbs (pound-mass). + * @return Lbs (pound-mass) converted from kilograms. + */ + public static double kilogramsToLbs(double kilograms) { + return kilograms / kKilogramsPerLb; + } + + /** + * Converts lbs (pound-mass) into kilograms. + * + * @param lbs The lbs (pound-mass) to convert to kilograms. + * @return Kilograms converted from lbs (pound-mass). + */ + public static double lbsToKilograms(double lbs) { + return lbs * kKilogramsPerLb; + } + } } diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/VelocityGeneration.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/VelocityGeneration.cs index 679941c..b276e71 100644 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/VelocityGeneration.cs +++ b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerate/VelocityGeneration.cs @@ -5,24 +5,20 @@ using System.Text; using System.Threading.Tasks; -namespace MotionProfileMapper.VelocityGenerate -{ - public class VelocityGeneration - { +namespace MotionProfileMapper.VelocityGenerate { + public class VelocityGeneration { private ProfilePath path; private List constrainedPathStates = new List(); private readonly double duration; private double[] pathStateStartTimes; - public VelocityGeneration() - { + public VelocityGeneration() { duration = 0; pathStateStartTimes = null; } public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryConstraints, double sampleDistance, - double trajectoryStartingVelocity, double trajectoryEndingVelocity) - { + double trajectoryStartingVelocity, double trajectoryEndingVelocity) { this.path = path; double distance = 0.0; @@ -35,14 +31,12 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon 0.0 ); - while (distance < path.getLength()) - { + while (distance < path.getLength()) { PState startingState = path.calculate(distance); double profileLength = sampleDistance; - if (distance + sampleDistance > path.getLength()) - { + if (distance + sampleDistance > path.getLength()) { profileLength = path.getLength() - distance; } @@ -52,8 +46,7 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon double maxEndingVelocity = Double.PositiveInfinity; - foreach (TrajectoryConstraint constraint in trajectoryConstraints) - { + foreach (TrajectoryConstraint constraint in trajectoryConstraints) { maxEndingVelocity = Math.Min(constraint.getMaxVelocity(endingState), maxEndingVelocity); } @@ -70,20 +63,16 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon double maxDeltaVelocity = maxEndingVelocity - startingVelocity; // Calculate the optimal acceleration for this profile - double optimalAcceleration = Math.Pow(maxDeltaVelocity, 2.0) / (2.0 * profileLength) + (startingVelocity / profileLength) * maxDeltaVelocity; - if (MathUtils.epsilonEquals(optimalAcceleration, 0.0)) - { + double optimalAcceleration = Math.Pow(maxDeltaVelocity, 2.0) / ( 2.0 * profileLength ) + ( startingVelocity / profileLength ) * maxDeltaVelocity; + if (MathUtils.epsilonEquals(optimalAcceleration, 0.0)) { // We are neither accelerating or decelerating state.acceleration = 0.0; state.endingVelocity = state.startingVelocity; - } - else if (optimalAcceleration > 0.0) - { + } else if (optimalAcceleration > 0.0) { // We are accelerating double maxStartingAcceleration = Double.PositiveInfinity; double maxEndingAcceleration = Double.PositiveInfinity; - foreach (TrajectoryConstraint constraint in trajectoryConstraints) - { + foreach (TrajectoryConstraint constraint in trajectoryConstraints) { maxStartingAcceleration = Math.Min(constraint.getMaxAcceleration(startingState, startingVelocity), maxStartingAcceleration); maxEndingAcceleration = Math.Min(constraint.getMaxAcceleration(endingState, startingVelocity), maxEndingAcceleration); // TODO: Use endingVelocity instead of startingVelocity } @@ -100,9 +89,7 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon state.endingVelocity = startingVelocity + acceleration * duration1; state.acceleration = acceleration; - } - else - { + } else { // If we can decelerate before we reach the end of the profile, use that deceleration. // This acceleration may not be achievable. When we go over the trajectory in reverse we will take care // of this. @@ -115,24 +102,20 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon distance += profileLength; } - for (int i = constrainedPathStates.Count - 1; i >= 0; i--) - { + for (int i = constrainedPathStates.Count - 1; i >= 0; i--) { ConstrainedPathState constrainedState = constrainedPathStates[i]; constrainedState.endingVelocity = trajectoryEndingVelocity; // Trajectory ending velocity - if (i != constrainedPathStates.Count - 1) - { + if (i != constrainedPathStates.Count - 1) { constrainedState.endingVelocity = constrainedPathStates[i + 1].startingVelocity; } // Check if we are decelerating double deltaVelocity = constrainedState.endingVelocity - constrainedState.startingVelocity; - if (deltaVelocity < 0.0) - { + if (deltaVelocity < 0.0) { // Use the deceleration constraint for when we decelerate double deceleration = Double.PositiveInfinity; - foreach (TrajectoryConstraint constraint in trajectoryConstraints) - { + foreach (TrajectoryConstraint constraint in trajectoryConstraints) { deceleration = Math.Min(deceleration, constraint.getMaxDeceleration(constrainedState.pathState, constrainedState.endingVelocity)); } @@ -143,8 +126,7 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon double decelDist = 0.5 * deceleration * Math.Pow(decelTime, 2.0) + constrainedState.endingVelocity * decelTime; // If we travel too far we have to decrease the starting velocity - if (decelDist > constrainedState.length) - { + if (decelDist > constrainedState.length) { // We can't decelerate in time. Change the starting velocity of the segment so we can. double[] roots = MathUtils.quadratic(0.5 * deceleration, constrainedState.endingVelocity, -constrainedState.length); @@ -161,39 +143,30 @@ public VelocityGeneration(ProfilePath path, TrajectoryConstraint[] trajectoryCon pathStateStartTimes = new double[constrainedPathStates.Count]; double duration = 0.0; - for (int i = 0; i < constrainedPathStates.Count; i++) - { + for (int i = 0; i < constrainedPathStates.Count; i++) { pathStateStartTimes[i] = duration; duration += constrainedPathStates[i].getDuration(); } this.duration = duration; } - public State calculate(double time) - { + public State calculate(double time) { int start = 0; int end = constrainedPathStates.Count - 1; - int mid = start + (end - start) / 2; - while (start <= end) - { - mid = (start + end) / 2; + int mid = start + ( end - start ) / 2; + while (start <= end) { + mid = ( start + end ) / 2; - if (time > pathStateStartTimes[mid] + constrainedPathStates[mid].getDuration()) - { + if (time > pathStateStartTimes[mid] + constrainedPathStates[mid].getDuration()) { start = mid + 1; - } - else if (time < pathStateStartTimes[mid]) - { + } else if (time < pathStateStartTimes[mid]) { end = mid - 1; - } - else - { + } else { break; } } - if (mid >= constrainedPathStates.Count) - { + if (mid >= constrainedPathStates.Count) { // Out of bounds return new State(path.calculate(0.0), 0.0, 0.0); } @@ -205,21 +178,17 @@ public State calculate(double time) return s; } - public double getDuration() - { + public double getDuration() { return duration; } - public ProfilePath getPath() - { + public ProfilePath getPath() { return path; } - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); - for (int i = 0; i < constrainedPathStates.Count; ++i) - { + for (int i = 0; i < constrainedPathStates.Count; ++i) { builder.Append(i); builder.Append(","); builder.Append(constrainedPathStates[i].pathState.toString()); diff --git a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerator.cs b/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerator.cs deleted file mode 100644 index b1b0c8b..0000000 --- a/Motion-Profile-Mapper/Motion-Profile-Mapper/VelocityGenerator.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System; -using System.Collections.Generic; -using static MotionProfile.ControlPoint; - -namespace MotionProfile.Spline -{ - public class VelocityGenerator - { - private double max_jerk = 10000; - private double max_vel = 1000; - private double max_acc = 2500; - private double p_target = 100; - //private ControlPointDirection direction; - private double dt=.01; - private S_Curve[] s_curve = new S_Curve[7]; - //public VelocityGenerator(double max_vel, double max_acc, double max_jerk, ControlPointDirection direction, double dt) - public VelocityGenerator(double max_vel, double max_acc, double max_jerk, double dt) - { - - this.max_vel = max_vel; - this.max_acc = max_acc; - this.max_jerk = max_jerk; - //this.direction = direction; - this.dt = dt; - - s_curve[0] = new S_Curve(0.0, 0.0, max_jerk, 0.0, 0.0, 0.0); // curve1 - s_curve[1] = new S_Curve(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // curve2 - s_curve[2] = new S_Curve(0.0, 0.0, -max_jerk, 0.0, 0.0, 0.0); // curve3 - s_curve[3] = new S_Curve(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // curve4 - s_curve[4] = new S_Curve(0.0, 0.0, -max_jerk, 0.0, 0.0, 0.0); // curve5 - s_curve[5] = new S_Curve(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // curve6 - s_curve[6] = new S_Curve(0.0, 0.0, max_jerk, 0.0, 0.0, 0.0); // curve7 - } - - public List GeneratePoints(double distance) - { - List list = new List(); - this.p_target = distance; - recalculate_s_curve(.01); - for (double time = 0; time < s_curve[6].t0 + s_curve[6].t; time += dt) - { - VelocityPoint point = new VelocityPoint(); - - point.Pos = s_curve_pos(s_curve, time); - point.Vel = s_curve_vel(s_curve, time); - point.Acc = s_curve_acc(s_curve, time); - point.Jerk = s_curve_jerk(s_curve, time); - point.Time = time; - - list.Add(point); - } - return list; - } - - - private void recalculate_s_curve(double tolerance) - { - - double t1 = 0; - double t2 = 0; - - // Compute a constant jerk S-curve profile with starting - // and ending velocity of 0 using max_jrk, max_acc, and - // max_vel. The total distance travelled by the curve will - // be "p_target". Maximum velocity may be reduced in order - // to reach p_target. - - double p = 0; - - double test_vel_min = 0; - double test_vel_max = max_vel; - double test_vel = test_vel_max; // Start at max vel - probably the solution - while ((test_vel_max - test_vel_min) > tolerance) // Solve to within 5 velocity units - { - if (Math.Pow(max_acc, 2) / max_jerk > test_vel) - { - t1 = Math.Pow(test_vel / max_jerk, 0.5); - t2 = 0; - } - else - { - t1 = max_acc / max_jerk; - t2 = (test_vel - max_acc * t1) / max_acc; - } - - s_curve[0].t = s_curve[2].t = s_curve[4].t = s_curve[6].t = t1; - s_curve[1].t = s_curve[5].t = t2; - calculate_s_curve(s_curve); - - p = s_curve_pos(s_curve, s_curve[6].t0 + s_curve[6].t); - - if (p > p_target) - { - // Need to reduce velocity - test_vel_max = test_vel; - test_vel = (test_vel_max + test_vel_min) / 2.0; - } - else - { - if (p > (p_target - tolerance)) - { - break; - } - else - { - // Increase velocity - test_vel_min = test_vel; - test_vel = (test_vel_max + test_vel_min) / 2.0; - } - } - } - - // Adjust the constant velocity section to reach the target position - double t = (p_target - p) / test_vel; - s_curve[3].t = Math.Max(t, 0); - calculate_s_curve(s_curve); - } - private void calculate_s_curve(S_Curve[] curve) - { - S_Curve last_curve = curve[0]; - for (var i = 1; i < 7; i++) - { - curve[i].t0 = last_curve.t0 + last_curve.t; - curve[i].a = s_curve_part_acc(last_curve, last_curve.t); - curve[i].v = s_curve_part_vel(last_curve, last_curve.t); - curve[i].p = s_curve_part_pos(last_curve, last_curve.t); - last_curve = curve[i]; - } - } - private double s_curve_pos(S_Curve[] curve, double time) - { - int i = s_curve_index(curve, time); - return s_curve_part_pos(curve[i], time - curve[i].t0); - } - private double s_curve_vel(S_Curve[] curve, double time) - { - int i = s_curve_index(curve, time); - return s_curve_part_vel(curve[i], time - curve[i].t0); - } - private double s_curve_acc(S_Curve[] curve, double time) - { - int i = s_curve_index(curve, time); - return s_curve_part_acc(curve[i], time - curve[i].t0); - } - private double s_curve_jerk(S_Curve[] curve, double time) - { - int i = s_curve_index(curve, time); - return s_curve_part_jerk(curve[i], time - curve[i].t0); - } - - private double s_curve_part_pos(S_Curve part, double time) - { - return part.p + part.v * time + - 1.0 / 2.0 * part.a * Math.Pow(time, 2) + - 1.0 / 6.0 * part.j * Math.Pow(time, 3); - } - - private double s_curve_part_vel(S_Curve part, double time) - { - return part.v + part.a * time + - 1.0 / 2.0 * part.j * Math.Pow(time, 2); - } - - private double s_curve_part_acc(S_Curve part, double time) - { - return part.a + part.j * time; - } - - private double s_curve_part_jerk(S_Curve part, double time) - { - return part.j; - } - - private int s_curve_index(S_Curve[] curve, double time) - { - int i; - for (i = 1; i < 7; i++) - { - if (curve[i].t0 > time) - { - break; - } - } - return i - 1; - } - } - public class VelocityPoint - { - private double pos; - private double vel; - private double acc; - private double jerk; - private double time; - - public double Pos - { - get - { - return pos; - } - set - { - pos = value; - } - } - public double Vel - { - get - { - return vel; - } - set - { - vel = value; - } - } - public double Acc - { - get - { - return acc; - } - set - { - acc = value; - } - } - public double Jerk - { - get - { - return jerk; - } - set - { - jerk = value; - } - } - public double Time - { - get - { - return time; - } - set - { - time = value; - } - } - } -}