Skip to content

Commit

Permalink
fix gimbal rearranger for DLC, director_strength in craft settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris-Barboris committed Aug 18, 2018
1 parent 80808bf commit 686c0bb
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 30 deletions.
12 changes: 6 additions & 6 deletions AAGpuWrapper/AAGpuWrapper.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -23,36 +23,36 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>AAGpuWrapper</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
<OutDir>$(SolutiontDir)..\GPUBins\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
<OutDir>$(SolutiontDir)..\GPUBins\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
<OutDir>$(SolutiontDir)..\GPUBins\$(Configuration)\</OutDir>
Expand Down
2 changes: 1 addition & 1 deletion AtmosphereAutopilot/AtmosphereAutopilot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
11 changes: 7 additions & 4 deletions AtmosphereAutopilot/AtmosphereAutopilot.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2047
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtmosphereAutopilot", "AtmosphereAutopilot.csproj", "{D8C77EB2-8B40-4ECB-9DA2-29682020C89B}"
EndProject
Expand All @@ -26,26 +26,29 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8C77EB2-8B40-4ECB-9DA2-29682020C89B}.Debug|x64.ActiveCfg = Debug|Any CPU
{D8C77EB2-8B40-4ECB-9DA2-29682020C89B}.Release|x64.ActiveCfg = Release|Any CPU
{D8C77EB2-8B40-4ECB-9DA2-29682020C89B}.Release|x64.Build.0 = Release|Any CPU
{FE12F262-92A5-4D94-B34C-E536FEBE651D}.Debug|x64.ActiveCfg = Debug|Any CPU
{FE12F262-92A5-4D94-B34C-E536FEBE651D}.Release|x64.ActiveCfg = Release|Any CPU
{3DBF4445-889C-4342-BDD6-35BEED699A14}.Debug|x64.ActiveCfg = Debug|Any CPU
{3DBF4445-889C-4342-BDD6-35BEED699A14}.Release|x64.ActiveCfg = Release|Any CPU
{3DBF4445-889C-4342-BDD6-35BEED699A14}.Release|x64.Build.0 = Release|Any CPU
{2FAD385F-1672-4EEF-8D43-50C31AC5D0D6}.Debug|x64.ActiveCfg = Debug|x64
{2FAD385F-1672-4EEF-8D43-50C31AC5D0D6}.Debug|x64.Build.0 = Debug|x64
{2FAD385F-1672-4EEF-8D43-50C31AC5D0D6}.Release|x64.ActiveCfg = Release|x64
{2FAD385F-1672-4EEF-8D43-50C31AC5D0D6}.Release|x64.Build.0 = Release|x64
{4A748F05-6D70-44C8-BC7D-E853CA9242A2}.Debug|x64.ActiveCfg = Debug|x64
{4A748F05-6D70-44C8-BC7D-E853CA9242A2}.Debug|x64.Build.0 = Debug|x64
{4A748F05-6D70-44C8-BC7D-E853CA9242A2}.Release|x64.ActiveCfg = Release|x64
{4A748F05-6D70-44C8-BC7D-E853CA9242A2}.Release|x64.Build.0 = Release|x64
{3DFB92BB-C1B6-4465-A2F3-895EC952CF18}.Debug|x64.ActiveCfg = Debug|x64
{3DFB92BB-C1B6-4465-A2F3-895EC952CF18}.Debug|x64.Build.0 = Debug|x64
{3DFB92BB-C1B6-4465-A2F3-895EC952CF18}.Release|x64.ActiveCfg = Release|x64
{3DFB92BB-C1B6-4465-A2F3-895EC952CF18}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3A78DC1B-1D13-4690-869D-33E3075530C3}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.TextStylePolicy = $1
Expand Down
6 changes: 3 additions & 3 deletions AtmosphereAutopilot/AtmosphereAutopilot.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"VERSION" : {
"MAJOR" : 1,
"MINOR" : 5,
"PATCH" : 10,
"PATCH" : 11,
"BUILD" : 0
},
"KSP_VERSION" : {
"MAJOR" : 1,
"MINOR" : 2,
"PATCH" : 2
"MINOR" : 4,
"PATCH" : 5
},
"KSP_VERSION_MIN" : {
"MAJOR" : 1,
Expand Down
37 changes: 26 additions & 11 deletions AtmosphereAutopilot/GimbalRearranger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ internal void Awake()
List<LoadingSystem> list = LoadingScreen.Instance.loaders;
if (list != null)
{
GameObject go = new GameObject("GimbalRearranger");
Rearranger ra = go.AddComponent<Rearranger>();
CSurfaceReplacer re = go.AddComponent<CSurfaceReplacer>();
list.Insert(list.Count - 1, ra);
list.Insert(list.Count - 1, re);
int partLoaderIdx = 0;
while (partLoaderIdx < list.Count)
{
if (list[partLoaderIdx].GetType() == typeof(PartLoader))
{
Debug.Log("[AtmosphereAutopilot]: PartLoader loader found, injecting mod loaders before it");
GameObject go = new GameObject("GimbalRearranger");
Rearranger ra = go.AddComponent<Rearranger>();
CSurfaceReplacer re = go.AddComponent<CSurfaceReplacer>();
list.Insert(partLoaderIdx, ra);
list.Insert(partLoaderIdx, re);
break;
}
partLoaderIdx++;
}
if (partLoaderIdx == list.Count)
Debug.LogError("[AtmosphereAutopilot]: PartLoader loader not found, unable to rearrange gimbals");
}

DontDestroyOnLoad(this);
Expand All @@ -50,16 +62,19 @@ public override void StartLoad()
if ((gimbal_node = part.nodes.GetNode("MODULE", "name", "ModuleGimbal")) != null)
{
if (move_node_first(gimbal_node, part))
{
handle_ModuleSurfaceFX(part);
Debug.Log("[AtmosphereAutopilot]: part '" + part.GetValue("name") + "' config node contains ModuleGimbal, moving it");
Debug.Log("[AtmosphereAutopilot]: part '" + part.GetValue("name") + "' config node contains ModuleGimbal, moving it");
}
}
else
if ((gimbal_node = part.nodes.GetNode("MODULE", "name", "KM_Gimbal_3")) != null)
else if ((gimbal_node = part.nodes.GetNode("MODULE", "name", "KM_Gimbal_3")) != null)
{
if (move_node_first(gimbal_node, part))
{
if (move_node_first(gimbal_node, part))
handle_ModuleSurfaceFX(part);
handle_ModuleSurfaceFX(part);
Debug.Log("[AtmosphereAutopilot]: part '" + part.GetValue("name") + "' config node contains KM_Gimbal_3, moving it");
}
}
}
ready = true;
}
Expand Down Expand Up @@ -120,7 +135,7 @@ public override void StartLoad()
if ((csurf_node = part.nodes.GetNode("MODULE", "name", "ModuleControlSurface")) != null)
{
Debug.Log("[AtmosphereAutopilot]: part '" + part.GetValue("name") + "' config node contains ModuleControlSurface, replacing it");
csurf_node.SetValue("name", "SyncModuleControlSurface", false);
csurf_node.SetValue("name", "SyncModuleControlSurface", false);
}
}
ready = true;
Expand Down
1 change: 1 addition & 0 deletions AtmosphereAutopilot/Modules/DirectorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected override void OnDeactivate()
yaw_c.moderate_aoa = sideslip_moderation_saved;
}

[VesselSerializable("strength")]
[AutoGuiAttr("strength", true, "G4")]
public double strength = 0.95;

Expand Down
11 changes: 11 additions & 0 deletions AtmosphereAutopilot/Modules/TopModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public CraftSettingsWindow(TopModuleManager manager)
PitchAngularVelocityController pvc;
YawAngularVelocityController yvc;
RollAngularVelocityController rvc;
DirectorController dc;

public bool mapped = false;

Expand All @@ -239,6 +240,7 @@ public void map_modues()
pvc = owner.cur_ves_modules[typeof(PitchAngularVelocityController)] as PitchAngularVelocityController;
yvc = owner.cur_ves_modules[typeof(YawAngularVelocityController)] as YawAngularVelocityController;
rvc = owner.cur_ves_modules[typeof(RollAngularVelocityController)] as RollAngularVelocityController;
dc = owner.cur_ves_modules[typeof(DirectorController)] as DirectorController;
mapped = true;
}

Expand Down Expand Up @@ -277,6 +279,10 @@ protected override void _drawGUI(int id)
GUILayout.Label("yaw rate limit", GUIStyles.labelStyleLeft);
float.TryParse(GUILayout.TextField(yvc.max_v_construction.ToString("G4"), GUIStyles.textBoxStyle), out yvc.max_v_construction);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("director strength", GUIStyles.labelStyleLeft);
double.TryParse(GUILayout.TextField(dc.strength.ToString("G4"), GUIStyles.textBoxStyle), out dc.strength);
GUILayout.EndHorizontal();

// wing leveler
rvc.wing_leveler = GUILayout.Toggle(rvc.wing_leveler, "Snap wings to level", GUIStyles.toggleButtonStyle);
Expand Down Expand Up @@ -359,6 +365,7 @@ public class SettingsProfile
public bool moderate_aoa, moderate_sideslip, moderate_g, moderate_g_hor, wing_leveler;
public float max_aoa, max_sideslip, max_g, max_g_hor;
public float ptich_v, roll_v, yaw_v;
public double dir_strength = 0.95;

public void Apply(CraftSettingsWindow wnd)
{
Expand All @@ -376,6 +383,7 @@ public void Apply(CraftSettingsWindow wnd)

wnd.rvc.wing_leveler = wing_leveler;
wnd.rvc.max_v_construction = roll_v;
wnd.dc.strength = dir_strength;
}

public SettingsProfile(CraftSettingsWindow wnd)
Expand All @@ -396,6 +404,7 @@ public SettingsProfile(CraftSettingsWindow wnd)

wing_leveler = wnd.rvc.wing_leveler;
roll_v = wnd.rvc.max_v_construction;
dir_strength = wnd.dc.strength;
}

public SettingsProfile() { }
Expand All @@ -415,6 +424,7 @@ public void Serialize(ConfigNode node)
profileNode.AddValue("ptich_v", ptich_v);
profileNode.AddValue("roll_v", roll_v);
profileNode.AddValue("yaw_v", yaw_v);
profileNode.AddValue("dir_strength", dir_strength);
node.AddNode(profileNode);
}

Expand All @@ -434,6 +444,7 @@ public static SettingsProfile Deserialize(ConfigNode node)
float.TryParse(node.GetValue("ptich_v"), out prof.ptich_v);
float.TryParse(node.GetValue("roll_v"), out prof.roll_v);
float.TryParse(node.GetValue("yaw_v"), out prof.yaw_v);
double.TryParse(node.GetValue("dir_strength"), out prof.dir_strength);
return prof;
}
}
Expand Down
6 changes: 3 additions & 3 deletions AtmosphereAutopilot/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AtmosphereAutopilot")]
[assembly: AssemblyCopyright("Copyright © 2015-2016")]
[assembly: AssemblyCopyright("Copyright © 2015-2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.10.0")]
[assembly: AssemblyFileVersion("1.5.10.0")]
[assembly: AssemblyVersion("1.5.11.0")]
[assembly: AssemblyFileVersion("1.5.11.0")]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Original author: Boris-Barboris.
Contributors:
* radistmorse (aka Morse on KSP forums) - Neo-GUI design and implementation.
* CraigCottingham - Cruise flight and speed control GUI refactoring, coordinate input to waypoint mode.
* Hotel26 - usability fixes for old-GUI Cruise flight waypoint control.

License: GNU GPL version 3

Expand Down Expand Up @@ -151,7 +152,7 @@ Hotkeys:
Middle-level model-reference controller, follows a setpoint of surface velocity and acceleration vectors. Input: velocity vector and acceleration vector. Output: AoA, sideslip and roll angular velocity.

Short GUI description:
* _strength_ - default value 0.95. Measure of agressiveness of acceleration output of MD. Precise control multiplies output acceleration by the factor of 0.4.
* _strength_ - default value 0.95. Measure of agressiveness of acceleration output of MD. Precise control multiplies output acceleration by the factor of 0.4. Serialized per vessel design.
* _roll stop k_ - default value 1.0, used to prevent overshooting, magic number.
* _angular error_ - error in radians between desired velocity vector and current one.
* _max angular v_ - estimate on current maneuver maximum angular velocity.
Expand Down Expand Up @@ -179,7 +180,7 @@ Short GUI description:
* _desired sideslip_ - output to "Sideslip controller".

## Pitch, roll and yaw angular acceleration controllers
Low level model-reference angular acceleration controllers. Input: desired angular acceleration. Output: pitch\roll\yaw control state.
Low level dynamics inversion angular acceleration controllers. Input: desired angular acceleration (and yaw output for roll controller). Output: pitch\roll\yaw control state.

Short GUI description:
* _Csurf output_ - current expected virtual control surface position, wich is usually lagged from control signal.
Expand Down

0 comments on commit 686c0bb

Please sign in to comment.