codepoet

[1.0.5] PWB Fuel Balancer v0.1.2 (3rd November 2015)

Recommended Posts

PWB Fuel Balancer

screenshot19.png

screenshot23.png

Version 0.1.1

[DOWNLOAD LINK REMOVED BY MODERATOR BECAUSE THAT SITE IS SADLY MALICIOUS NOW]

Source Code on Github

Licensed under CC BY terms (attribution)

Tested with KSP 0.90

Mod to automatically move fuel between tanks to return the Centre 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 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

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. See the README for an email address to send them to.

Edited by Deddly
Had to remove download link :(

Share this post


Link to post
Share on other sites

Your add-on is missing a license and source code must be published prior to or when your download link is published. You may re-add your download link when both of these documents are made available.

Please see the add-on posting rules prior to posting.

Share this post


Link to post
Share on other sites

I doubt it's against the rules but you released the mod for an obsolete version of KSP.

Share this post


Link to post
Share on other sites

Oooops. Forgive the faux-pas. License and source are now available and ithas been tested with 0.21.

Share this post


Link to post
Share on other sites

Has this been tested on liquid fuel tanks? Trying to use it for my atmospheric planes and it seems to have a lot of trouble finding a CoM when the differences are <100 units.

Works great on my VAB ships!

Share this post


Link to post
Share on other sites

One suggestion. Change the name. :) Something like "Center of Mass Balancer" or something similar. The current "Fuel Balancer for RCS" makes it seem like it only moves monopropellant around. Ironic as this is the holy grail of Balance - there's a name! :D - that a lot of other mods have been reaching for. The only thing this mod is missing is the ability to specify a new center of mass position in flight.

Share this post


Link to post
Share on other sites

To be honest I am not really into spaceplanes for I have not tested it on trying to keep a space plane stable in flight (although I suppose the principle is that it should work if it can keep the CoM in the location over CoT that you designed into the spaceplane.)

However I suspect that there are a couple of problems:

1) As I don't ever go in the SPH I can not even confirm if the CoM target gets set if you use it is the SPH. I will have to check this - if not I expect it is easily fixed.

2) At the moment it does not move large amounts of fuel quickly, and it does not try to do anything with maximum flow rates, or take into account the Physics frame rate. So ideally it should know what the maximum amount of fuel it could move between takes is based on the maximum rates of flow and work from there. As it is it starts by moving a fixed amount each physics frame (1 unit?) and if it can't improve the situation, then it tries smaller amounts.

I will do some work on this when real life allows and let you know...

Orphican, you are right, the name is not great - to be honest was not the major part of the work! Perhaps a better name will emerge as more features are added, and it become clearer what it can do!

Share this post


Link to post
Share on other sites

Hmm, intersting - I just had a go in the SPH, and the CoM error is huge right from the runway. Could this be because I need to take into account some sort of change in the geometry in the SPH (ie up is not up it is forwards)? Does anyone know anything about this?

Share this post


Link to post
Share on other sites

Version 0.0.4 released:

Download

New in this release:

* 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

Share this post


Link to post
Share on other sites

I'm wondering if it would be possible to enable functionality of this in all command pods, similar to MechJeb or Engineer. That way there's no need for a separate part. The added benefit of that is, future updates won't break saves.

Share this post


Link to post
Share on other sites
I'm wondering if it would be possible to enable functionality of this in all command pods, similar to MechJeb or Engineer. That way there's no need for a separate part. The added benefit of that is, future updates won't break saves.

Possibly, probably. Try adding

    MODULE
{
name = PWBKSPFuelBalancer
}

to the command module part, and see if it works. It probably will, and means I will not have to worry about everyone laughing at my crappy control box (I am a coder at heart, not a modeller).

However this will not resolve the breaking of backwards compatibility I am afraid. The issue is that version 0.0.3 would store the vector from the part to the target CoM location after making the assumption that the vessel was pointing up (and trying to take account of this in the SPH where the vessel is not pointing up. However this did not really work, especially if you started rotating the whole vessel in the VAB or moved a vessel from SPH to VAB, (ie a rover), rotated it and mounted it on a launcher. So in version 0.0.4 it store the orientation of the part and the vector to the target CoM, so you can rotate your vessel all you like and it works. If I was willing to put more effort in I could have written code to attempt to migrate, but it probably would not work for all scenarios - I will give it a go for the next release, so not all is lost (in space!).

Another reason for keeping my ribbish control box is so that you can mount more than on on a vessel. I have discovered that this is quite handy for my universal tug / lander that can carry payloads either ontop or slung underneath (for landing) or have none. I can have two sets of RCS (ie the classic 2 rings of 4 4way thrusters) and use an action group to turn them on or off, which give me three locations for the CoM (either set or both together), and therefore I have 3 of my control units and be able to use one of them to balance the vessel even when I have lots of differing irregular payloads. See the pictures below:

screenshot9.png

As a lander with the payload slung underneath. Balance is set up for the lower set of RCS thrusters

screenshot22.pngWith the payload ontop, and balance achieved using the top set of thusters.

In theory I could have a toug with longer fuel tanks eitherside and more rcs / PWB balancing units and balacer pretty much any payload. It is a very useful craft for building in orbit.

Share this post


Link to post
Share on other sites

Haven't tried this mod with 0.22 yet, does it work?

Share this post


Link to post
Share on other sites
Haven't tried this mod with 0.22 yet, does it work?

I am just moving over to 0.22 myself today. If it does not work, I will be fixing it soon.

Share this post


Link to post
Share on other sites

I copy-pasted the tech tree integration stuff from MechJeb, it worked beautifully.

Share this post


Link to post
Share on other sites

I'm having some trouble with this mod, I am able to set the centre of mass. After launch, the marker shows that the CoM has moved, but the error is always reported as 0, and the fuel is not moved around when its told to balance.

I have tried this on two saves, here is a persistent save that has a ship with the issue. (Only ship in the save)

Mods I am also using: Editor Extensions, Engineer Redux, KAS, Kethane, Protractor, RCS Build Aid, & Kerbal Alarm Clock.

I checked the log, there were no noticeable errors.

Edit: After further testing I think I have solved the mystery. It seems the balancer only activates after it staged? Depending which stage I am in, it will suddenly activate, and start displaying the CoM error. There doesn't seem to be any way to control at which stage it starts reporting the CoM error. I think it only turns on on the very last stage.

Edited by starcitsura
Found the issue!

Share this post


Link to post
Share on other sites
I'm having some trouble with this mod, I am able to set the centre of mass. After launch, the marker shows that the CoM has moved, but the error is always reported as 0, and the fuel is not moved around when its told to balance.

I have tried this on two saves, here is a persistent save that has a ship with the issue. (Only ship in the save)

Mods I am also using: Editor Extensions, Engineer Redux, KAS, Kethane, Protractor, RCS Build Aid, & Kerbal Alarm Clock.

I checked the log, there were no noticeable errors.

Edit: After further testing I think I have solved the mystery. It seems the balancer only activates after it staged? Depending which stage I am in, it will suddenly activate, and start displaying the CoM error. There doesn't seem to be any way to control at which stage it starts reporting the CoM error. I think it only turns on on the very last stage.

Sorry for the bad support - I have only just realised that you have posted this. Yes, you are correct, it only starts moving fuel around once the stage that it is in has become active (more specificly it depends how far up the stack you attach the unit). I have not really given this aspect of it much thought - I just wrote it to do what I needed it for. However I would welcome feed back from other users - would it be better if this aspect of its functionality was developped somehow, and if so how do you suggest I make it work?

Edited by codepoet
clarifying my post.

Share this post


Link to post
Share on other sites
Yes, you are correct, it only starts moving fuel around once the stage that it is in has become active (more specifically it depends how far up the stack you attach the unit). I have not really given this aspect of it much thought - I just wrote it to do what I needed it for. However I would welcome feed back from other users - would it be better if this aspect of its functionality was developed somehow, and if so how do you suggest I make it work?

I'm having similar problems with getting the part to start working. I'm building a Space shuttle style launcher. I can get the last balancer to work on the last stage but I can't get the part to work for the launch stage. From the last post I assume that it looks at the height of the part it is attached to and figures out what stage it is in by what is below it in the stack. How does this work in the SPH? Does this work for boosters or onion style? Maybe you can have it show up in the staging list?

Share this post


Link to post
Share on other sites

Exactly what I was looking for and perfect for my huge SSTO's, I think.

Share this post


Link to post
Share on other sites

installed this yesterday, and am now affected with the MK1 command pod science unavailability bug. anyone else reported this?

Share this post


Link to post
Share on other sites
installed this yesterday, and am now affected with the MK1 command pod science unavailability bug. anyone else reported this?

I have not heard of that problem before. If you can provide a few more details about what the problem is and how to reproduce it, I will take a look to see if I can work out what is causing it.

Share this post


Link to post
Share on other sites

i'm not saying your mod was the cause, its just when it showed up. its a common bug, the MK1 command pod becomes greyed out and "requires purchase in R&D" but buying it does nothing and it stays that way. ive already fixed it by creating a dummy duplicate as a mod part.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.