linuxgurugamer

[1.5+, 1.6+] PWB Fuel Balancer Restored & Resource Jettisoning

Recommended Posts

Originally written by @codepoet, then maintained for a while by @Papa_Joe, this is another fuel-balancing mod.  Original thread is here: https://forum.kerbalspaceprogram.com/index.php?/topic/39263-105-p, second thread is here: https://forum.kerbalspaceprogram.com/index.php?/topic/147144-113-pwb-fuel-balance

After numerous attempts to contact @Papa_Joe, I've adopted this mod and made some improvements

 

What is PWB Fuel Balancer?

Mod to automatically move fuel between tanks to return the Center of Mass to a preset position for that your vessel is perfectly balanced for RCS operations, or any other reason.

The PWB Fuel Balancer allows an optimum location for the Center of Mass of a vessel to be set in the VAB or SPH and then for fuel to be pumped between tanks in flight in order to move the CoM back to that location when they are part full. This is intended to allow for perfect RSC control, allowing for rotation without translation and translation without rotation, assuming that the RCS thrusters have been perfectly located with reference to the CoM location. It is recommended that you also use the RCS Build Aid mod to exactly location the RCS thrusters. It has also been found to be useful for helping spaceplanes maintain balance as they consume fuel.

It is possible to display a (green) marker to indicate the centre of mass in the VAB/SPH by mousing over the part and pressing D. Set the optimum CoM location by mousing over the part and pressing M.

You can display the CoM marker and optimum CoM marker inflight by right clicking on the park, and choosing "toggle marker"

There is also a GUI that can be activated via the app launcher that allows to the manual positioning of the CoM target, both in the VAB and in flight.

New Features

  • Added ability to jettison resources.  Currently a max of 3 resources are available per part,and empties at a rate of 1% of the maximum tank volume/sec, meaning that a full tank will take 100 seconds to empty.  To use, right-click on a part which contains resources.  You can either jettison from that part only, or all parts with that resource
  • Added Settings page with the following
    • Specify whether jettison should continue when switching scenes
    • Added color settings sliders to settings page for the edge pulsing color
  • Added edge pulsing to show which parts are venting

Usage:

To set the CoM position -

  1. Add the PWB Fuel Balancer to your craft.  The optimum CoM is set to the current CoM when the part is placed, you can change it anytime
  2. Remove any stages that will not be present when using RCS
  3. Press 'M' to set the CoM position.
  4. Press 'D' to display the CoM position

To rebalance in flight right click the PWB Fuel Balancer part, or set an action key in the VAB/SPH.

 

Availability

Donations gratefully accepted

Patreon.png

https://www.patreon.com/linuxgurugamer

Mod Dependencies: 

Supports

  • KSP-AVC. This mod checks your installed mod versions against the mod's latest version. Let's you know when you need to update.  
  • CKAN. The Comprehensive Kerbal Archive Network (CKAN) Package Manager (CKAN) is a multi-platform app that manages nearly all your mods from one clean executable. Performs installs, updates, and uninstalls of your mods automatically.

What is PWB Fuel Balancer?

Mod to automatically move fuel between tanks to return the Center of Mass to a preset position for that your vessel is perfectly balanced for RCS operations, or any other reason.

The PWB Fuel Balancer allows an optimum location for the Center of Mass of a vessel to be set in the VAB or SPH and then for fuel to be pumped between tanks in flight in order to move the CoM back to that location when they are part full. This is intended to allow for perfect RSC control, allowing for rotation without translation and translation without rotation, assuming that the RCS thrusters have been perfectly located with reference to the CoM location. It is recommended that you also use the RCS Build Aid mod to exactly location the RCS thrusters. It has also been found to be useful for helping spaceplanes maintain balance as they consume fuel.

It is possible to display a (green) marker to indicate the centre of mass in the VAB/SPH by mousing over the part and pressing D. Set the optimum CoMlocation buy turning of CoM in the VAB/SPH, mousong over the part and pressing M.

You can display the CoM marker and optimum CoM marker inflight by right clicking on the park, and choosing "toggle marker"

There is also a GUI that can be activated via the app launcher that allows to the manual positioning of the CoM target, both in the VAB and in flight.

Usage:

To set the CoM position -

  1. add the PWB Fuel Balancer to your craft
  2. remove any stages that will not be present when using RCS
  3. turn on the CoM indicator
  4. mouse over the PWB Fuel Balancer part
  5. press 'M' to set the CoM position.
  6. press 'D' to display the CoM position

To rebalance in flight right click the PWB Fuel Balancer part, or set an action key in the VAB/SPH.

 

 

Release History

Spoiler

0.1.5

  • Adoption by LinuxGuruGamer
  • Removed old class: PwbkspFuelBalancer, was in for compatibility with old games
  • Commented out code which prevented click-through
  • Fixed the adjustment of the target to depend on the vessel type, either Plane or anything else
  • Added new KSPEvent to set the COM, also created method SetCOM which is called from other places
  • Added screen message telling player to turn on the COM if it isn't when trying to set a target
  • Added code to show the markerCam only when in flight
  • Fixed case of RotationInEditor (r had been lowercase)
  • Improved the SetCoM code so that the CoMmarker does not have to be on in the editor
  • Added message to window when no fuel balancers are mounted on the vessel
  • Added code to properly find fuel balancers when ship loaded in editor
  • Moved adding methods to GameEvents to the Awake instead of the Start
  • Added logging class
  • Replaced toolbar code with the ToolbarController
  • Deleted commented out code

0.1.3

  •  * Support of mod changed hands to Papa_Joe from codepoet  (Thanks codepoet!).
  • * Updated to be compatible with KSP 1.1.3.
  • * Restructured solution to allow for automated build and deploy
  • * Refactored code to improve organization, performance, reduce garbage collection, and use explicit typing.
  • * Got rid of the "horrible" fixedUpdate editorpartcount methodology.  implemented OnEditorShipModified for event driven handling of vessel part count changes. (codepoet knows what I mean  )
  • * Added close button to the upper right of the Fuel Balancer window.
  • * Added scene specific window positioning. Editor now starts just to the right of the parts list.  Flight now starts a safe margin to the right of the staging tree.

0.1.2

  • * Rebuilt for KSP 1.0.5
  • * New control box model (Thanks Skalou)
  • * Semi transparant markers (Thanks Skalou)

0.1.1

  • Added display/hide target marker to the UI
  • Added 2 save slots to the UI

0.1

  • Rebuilt against KSP 0.90
  • Added UI
  • Enabled the naming of individual balancers
  • Enabled the manual moving of balancers in flight and in the editor.

0.0.6

  • Updated for KSP 0.23.5
  • changed to be operating from launch rather than when its stage is staged.
  • Renamed the balancing module and part and provided legacy support for existing craft and saves.

0.0.5

  • Added the part to the "Large Control" tech tree and tested for 0.22 and 0.23

0.0.4

  • Fixed bugs that occur when the whole vessel is rotated in the editor. Unfortunately this will break backwards compatability (craft created with 0.0.3 will not have the correct CoM location set without returning to the VAB)
  • Added markers to show CoM and optimum CoM locations in VAB and in flight

0.0.3

  • Added prompts to the VAB / SPH to let the user know when the target CoM has been set
  • Fixed a bug that caused the CoM to be set in the wrong location in the SPH
  • Changed maintaince mode to continue attempting to balance even when a perfect solution is not possible.
  • Changed the name of the part to reflect the fact that it is not just useful for RCS

0.0.2

  • Added option of Maintain Balance - useful to account for CoM errors that arise when monopropellant is used during RCS manouvers
  • Added the ability for the part to report when it is not possible to achieve a perfect balance.

0.0.1

  • Initial Release

Bugs, comments and requests are welcome. Please create an issue in Github for any requests or bugs.

 

 This mod was originally created by @codepoet

Edited by linuxgurugamer

Share this post


Link to post
Share on other sites

Looks like a nice substitute for the old TAC Fuel Balancer.  It would be even nicer if a special component wasn't necessary so I could use it on existing craft out in space.  Thanks!

Share this post


Link to post
Share on other sites
On 12/25/2018 at 11:48 AM, HeadHunter67 said:

Looks like a nice substitute for the old TAC Fuel Balancer.  It would be even nicer if a special component wasn't necessary so I could use it on existing craft out in space.  Thanks!

That special part is used to store the i fo,  y putting multiple on a craft you can have multiple setups.

Share this post


Link to post
Share on other sites

New release, 0.1.5.1

  • Fixed bug where locked tanks would still be filled/emptied

Share this post


Link to post
Share on other sites

New release, 0.1.5.2

  • Improved the locked tank code
  • Added ability to jettison resources.  Currently a max of 3 resources are available per part,and empties at a rateof 1%/sec
  • Optimized code by replacing string comparisons with an Enum. Kept the string for display purposes

Share this post


Link to post
Share on other sites

New release, bug fix 0.1.5.3

  • Fixed a problem with the jettison code, which was failing on vessels with many parts & tanks
     

Share this post


Link to post
Share on other sites

New release, 0.1.5.4

  • Fixed jettison code to work properly on multiple vessels and on scene switches
  • Added Settings page to specify whether jettison should continue when switching scenes
  • Added edge pulsing to show which parts are venting
  • Added color settings sliders to settings page

Share this post


Link to post
Share on other sites

New release, 0.1.5.5

  • Added toggles for Saved CoM and Actual CoM
  • Added flag to use KSP skin

Share this post


Link to post
Share on other sites

New release, 0.1.5.6

  • Minor optimizations by commenting out unused callbacks
  • Fixed harmless nullref in editor when deleting the PWB part

Share this post


Link to post
Share on other sites

This mod doesn't do anything with the graphics. 

I've seen this with stock also

Share this post


Link to post
Share on other sites
2 minutes ago, linuxgurugamer said:

This mod doesn't do anything with the graphics. 

I've seen this with stock also

I've seen similar transparency happen with Navhud. But I can produce the transparency just by installing the mod, it's not even activated in the above screenshot.
Maybe an issue with the InFlightMarkerCam?

Share this post


Link to post
Share on other sites
3 minutes ago, Zah said:

I've seen similar transparency happen with Navhud. But I can produce the transparency just by installing the mod, it's not even activated in the above screenshot.
Maybe an issue with the InFlightMarkerCam?

I'll take a look at it

Share this post


Link to post
Share on other sites
31 minutes ago, linuxgurugamer said:

I'll take a look at it

Now that I'm closing in, I did some more testing and can also cause the same transparency when turning on Kerbal Flight Indicators or NavHud. So must be the camera they produce. Now if that's something unique to my system (nvidia) or a KSP issue... I've seen the transparency on Das's stream when he used NavHud.

Edited by Zah

Share this post


Link to post
Share on other sites
17 hours ago, Zah said:

Now that I'm closing in, I did some more testing and can also cause the same transparency when turning on Kerbal Flight Indicators or NavHud. So must be the camera they produce. Now if that's something unique to my system (nvidia) or a KSP issue... I've seen the transparency on Das's stream when he used NavHud.

I can confirm it, but I have no idea what's going on, that part of it isn't my code.

I'll be asking for some help on this

Share this post


Link to post
Share on other sites
1 hour ago, linuxgurugamer said:

I can confirm it, but I have no idea what's going on, that part of it isn't my code.

I'll be asking for some help on this

Thank you!
With the camera "always on" in PWB Fuel Balancer it was more apparent than in NavHud so I started testing.

Took about three evenings of cycling through 200 mods. It was literally the last mod in my binary search because I put it in a group of "non-graphics related".

You can imagine how confused I was when I was done with the "graphics-related mods" and the issue was still there. I even looked through texture files trying to find something.

The transparency seems to require light (duh) on the surface, in my above screenshot the sun is in the west of KSC. So maybe it's a bug with the way the game does specular shaders? I have no idea how this works in Unity/KSP.

Edit: Two screenshots -- same game state. Against the light shows no transparency, but once you have a surface that reflects light you see it.
https://imgur.com/a/0aJBfZS

A few further screenshots with other parts:
https://imgur.com/a/w3liJBXB

Edited by Zah

Share this post


Link to post
Share on other sites

Could you repost this in the new thread I created about this problem?

Share this post


Link to post
Share on other sites

New release, 0.1.5.7

  • Fixed issue with the mod making parts semitransparent in certain circumstances

Share this post


Link to post
Share on other sites

Thank you so much! I will check tomorrow, already in bed.

Share this post


Link to post
Share on other sites

New release, 0.1.5.8

  • Fixed nullref when doing a jettison All

Share this post


Link to post
Share on other sites

Not working for me. when I right click on the "PWB Fuel Balancer", the only option I have is "aim camera" :(

The resource jettisoning was also unavailable.

Share this post


Link to post
Share on other sites
3 hours ago, Angleton said:

Not working for me. when I right click on the "PWB Fuel Balancer", the only option I have is "aim camera" :(

The resource jettisoning was also unavailable.

Did you install the dependencies as well?

On 12/8/2018 at 4:07 AM, linuxgurugamer said:

If you want to be able to jettison fuel as well, you will also need ModuleManager:

*cough* this isn't mentioned anywhere so far, incl. CKAN *cough* @linuxgurugamer ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.