Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1492 steering manager disassociation #1544

Conversation

hvacengi
Copy link
Member

@hvacengi hvacengi commented Mar 15, 2016

Fixes #123
Fixes #1492
Fixes #1587
Fixes #1608

This is my "progress" update for the code to fix the issue of disassociation of the steering manager from the CPU vessel. It serves as a fairly sweeping overhaul for how the steering manager is used, so that the manager itself exists only once and is managed by a VesselModule. Eventually (possibly before this PR is complete) I intend to move everything that is "vessel" specific rather than "part" specific into this module (or at least to be managed by the module). While working on some other items, I realized I was starting to diverge into some similar changes as what I did in this branch, so I wanted to make sure that I got it posted and published so that every one can kick me to make sure it gets finished.

Features:

  • Implement new VesselModule
  • Add new IFlightControlParameter interface
  • Move SteeringManager to Control namespace and implement `IFlightControlParameter
  • Use new KSP 1.1 ITorqueProvider interface for calculating potential torque
  • Remove now abandoned methods and fields with the elimination of our own torque calculation
  • Depreciate old suffixes that no longer function
  • Document depreciated suffixes
  • Fixes to PIDLoop

@hvacengi hvacengi added the Not Ready Author is warning Reveiwer not to merge this PR yet. More edits are expected. label Mar 15, 2016
@hvacengi hvacengi self-assigned this Mar 15, 2016
@hvacengi hvacengi added this to the v1.0.0 milestone Mar 15, 2016
@hvacengi hvacengi force-pushed the issue-1492-steering_manager_disassociation branch 4 times, most recently from 494c0e6 to aafb646 Compare April 17, 2016 05:02
kOSVesselModule.cs
* Implement new vessel module to manage vessel specific values
* Manage steering manager
IFlightControlParameter.cs
* New interface for flight controls
kOS.csproj
* Reference the new files
FlightControlManager.cs
* Stop using SteeringManagerProvider, and reference the new vessel
module instead
FlightStats.cs
* Get the STEERINGMANGER from the vessel module instead of the provider
SteeringManager.cs
* Implement IFlightControlParameter interface
* Stop using provider
SteeringManagerProvider.cs
* Removed abandoned class
kOS.csproj
* Remove reference to SteeringManagerProvider.cs
IFlightControlParameter.cs
* Added methods for UpdateValue, GetValue, GetShared, and CopyFrom.
* Probably will eventually remove the Value property
FlightControlManager.cs
* Update to ControlPartId
kOSVesselModule.cs
* Switch to Vessel.id based tracking to simplify dictionary lookup
* Add initialized flag to prevent random instances of FixedUpdate being
called before Start.
* Don't remove parts from partLookup when clearing the childParts list.
* Clear partLookup in Destroy if no other VesselModules remain (should
only occur if switching to a vessel out of range of the current vessel,
or when changing scenes)
* Copy flight control parameters when experiencing a staging or docking
event.
* Manage enable/disabling parameters for vessel changes too.
SteeringManager.cs
* Implement new interface methods
* Retask old copy logic
* Fix stopwatch that broke in the last commit.
SteeringManager.cs
* Reduce the value of EPSILON to help with fine steering control.
* Fixes a particular issue where large torque values and *very* small
MoI's resulted in steering based on the integral component which was
prone to running away uncontrollably.
SteeringManager.cs
* Use UpdateHandler.CurrentFixedTime instead of planetarium time
(smaller value, less chance for floating point errors)
* Update the state vectors and display vectors if SAS is enabled
* Hide angular velocity, rcs, and engine thrust display vectors when SAS
is enabled.
* Don't throw an exception when getting target direction, throwing an
exception won't trigger the kOS logger.  Instead, log the exception
directly.
PIDLoop.cs
* Update integral/derivative logic to use the previous dTerm and iTerm
if dt is not greater than 0.
IFlightControlParameter.cs
* Remove Value property and UpdateValue method that supported setting
the value without passing SharedObjects
FlightControlManager.cs
* Remove references to removed properties
SteeringManager.cs
* Removed MoI adjustment logic, the stock MoI calculation has been
improved to be much more accurate.  Leaving torque adjustment for now to
account for control surfaces.
* Fixes KSP-KOS#1588 check the rcs module's new pitch, yaw, and roll enable
properties
kOSVesselModule.cs
* Change Awake method to OnAwake to prevent breaking KSP1.1's ability to
save fields on VesselModule
@hvacengi hvacengi force-pushed the issue-1492-steering_manager_disassociation branch from aafb646 to a627a22 Compare April 18, 2016 15:59
Moved SteeringManager.cs from kOS/Binding to kOS/Control
Change SteeringManager.cs namespace and add reference to kOS.Control
namespace where needed.
SteeringManager.cs
* Convert steering logic to use ITorqueProvider
* Disabled torque adjustment by default.
kOSVesselModule.cs
* Add event handler to destroy the module when the vessel docks to
another vessel.  This was preventing the module from re-initializing and
subscribing to autopilot events.
* Refactor method names to match kOS style recomendations.
* Add XML documentation to all methods.
SteeringManager.cs
* Remove old logic that's no longer in use (engine/rcs vectors, torque
calculation, ForceVector class)
* Throw deprecation exceptions for SHOWTHRUSTVECTORS and SHOWRCSVECTORS
Fixes KSP-KOS#1608

PIDLoop.cs
* fix issue where ResetI was not resetting the ITerm itself.
@hvacengi hvacengi force-pushed the issue-1492-steering_manager_disassociation branch from 6fa0568 to 89b55da Compare April 29, 2016 15:54
@hvacengi hvacengi added the Pending Documentation Author is warning Reviewer not to merge this PR yet. User doc changes aren't in the PR yet. label Apr 29, 2016
Update documentation to reflect deprecating SHOWRCSVECTORS and
SHOWTHRUSTVECTORS.
@hvacengi hvacengi removed Not Ready Author is warning Reveiwer not to merge this PR yet. More edits are expected. Pending Documentation Author is warning Reviewer not to merge this PR yet. User doc changes aren't in the PR yet. labels Apr 29, 2016
@hvacengi
Copy link
Member Author

This should now be ready for review and merging. I will leave the migration of other steering parameters to another PR so that these rather important fix can get merged for the next release.

@hvacengi hvacengi removed their assignment Apr 30, 2016
SteeringManager.cs
* Provide temporary fix for MoI calculation, to be removed after KSP's
next update.
@hvacengi hvacengi added the Breaking Some user scripts that used to work will break (even if just in a minor way). label May 2, 2016
@hvacengi
Copy link
Member Author

hvacengi commented May 2, 2016

This is technically breaking because I depreciated 2 suffixes (SHOWTHRUSTVECTORS and SHOWRCSVECTORS)

SteeringManager.cs
* Move conversion of the "set" value from inside the autopilot update
and into the actual set method itself.  This means that a conversion
exception will break execution and display the error (on the next
physics tick) preventing further script execution.

KSPLogger.cs
* Remove requirement for null or empty filepath for noting that an
exception is in the built-in steering update (previously this line was
not getting triggered unless called from the interpreter).
@hvacengi hvacengi force-pushed the issue-1492-steering_manager_disassociation branch from a1ed8b0 to dc2277f Compare May 9, 2016 16:39
@hvacengi
Copy link
Member Author

hvacengi commented May 9, 2016

I've updated this to throw an exception when setting the steering value to an unsupported type. This will cause it to break execution, instead of silently disabling steering and continuing execution.

I also fixed it so the trace log will identify the error as part of the built in steering update. I really wanted to make it properly identify the line causing the error, but that's really complicated given how the trigger is created.

kOSVesselModule.cs
* Changed logger calls to `SuperVerbose` instead of `LogError` so that
they are hidden under "release" builds.
// We only want to copy the parameters themselves once (because they are vessel dependent
// not part dependent) but we still need to iterate through each part since "control"
// itself is part dependent.
if (partLookup[id].ID != BaseId) paramDestination.CopyFrom(paramOrigin);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to change this logic to only copy "enabled" parameters, or perhaps only "enabled" parameters who's controlling part is on the new vessel. This could be done pretty easily by moving the copy line into the if block below. I'm open to discussion on it though.

@tomekpiotrowski tomekpiotrowski merged commit 9bb00ab into KSP-KOS:develop May 12, 2016
@tomekpiotrowski tomekpiotrowski modified the milestones: v0.20.1, v1.0.0 May 12, 2016
@hvacengi hvacengi deleted the issue-1492-steering_manager_disassociation branch May 12, 2016 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Some user scripts that used to work will break (even if just in a minor way).
Projects
None yet
2 participants