Jump to content

[1.4] StageRecovery - Recover Funds+ from Dropped Stages - v1.8.0 (March 11, 2018)


magico13

Recommended Posts

This is a spinoff addon from my addon Kerbal Construction Time containing only the booster recovery code. I split it off since 0.24 makes recovery of spent stages practical in the stock game. This mod allows funds to be recovered, at a reduced rate, from dropped stages so long as they have parachutes attached (not necessarily deployed).

What can this mod do:

  • Recover funds from stages that have enough parachutes to drop the terminal velocity to a safe level
  • Two funds recovery models: Flat Rate, where once the velocity drops below a cutoff a flat rate is returned; or Variable Rate (default), where the velocity within an intermediate range determines the recovery percentage (following a quadratic relationship)
  • Recovery percentage (flat rate model only) is configurable (default of 75% of the normal for the current distance from KSC, 100% if a probe core or Kerballed command pod is attached)
  • Works with Stock parachutes and Real Chutes parachutes
  • All cutoff velocities are easily configurable with in-game sliders in the in-game settings menu
  • Recovery does not require that parachutes are deployed, only attached (but it is a good idea to deploy them at low altitudes)
  • Recover Kerbals in dropped/returned stages (improved in 1.6.0, hopefully no more contract failures)
  • Recover science in dropped/returned stages
  • Integrates with stock message system (reports can be disabled in the setting file)
  • Easy to use, non-intrusive GUI for viewing Recovered and Destroyed Stages.
  • Editor helper to help you figure out just how many parachutes you need.
  • Has an easy to use API that other mods can tie into to be notified of recovery events (success or failure)
  • Support for KSP-AVC for version checking
  • Powered recovery of stages. Land with rockets, instead of just parachutes!
  • Unfocused stages can be destroyed by thermal heating if they are going too fast (check below for further details, it's not exactly a scientific way of handling this)
  • Designed to work alongside FMRS! If FMRS is deactivated, SR will handle recovery. If FMRS isn't handling parachute stages or has deferred them to SR, then SR will handle them while FMRS handles controlled stages.
  • With 1.7.1, more advanced support for FMRS. With the new RecoveryController integration you can designate stages to be recovered by StageRecovery, FMRS, auto, or no mods during construction or flight.

 

Powered Recovery requirements:

Spoiler

Now you can be your very own Elon Musk and have your rockets land with their engines! This feature is a work in progress, however, and will be improved in future updates. With that said, if you are having issues with recovery, first try going into the settings and disabling Powered Recovery, then you can report your bugs if they didn't go away.

So, what are the requirements for powered recovery?

  • An activated engine (or multiple), excluding SolidFuel powered engines (engine ISP will be properly averaged).
  • Atmospheric Delta-V of at least 1.5 times the terminal velocity after parachutes. (about 300 m/s without chutes, otherwise just 1.5x the terminal velocity indicated in the editor helper)
  • A point of control, such as a probe body or Kerballed command pod, that has SAS capabilities (so a Pilot kerbal or a probe with SAS)
  • A total Thrust-To-Weight ratio of greater than 1. Even if using parachutes.

 

Explicitly calculating the fuel amounts required for every engine is hard. Several approximations are made:

  1. All engines are averaged together to act as a single engine.
  2. All required propellant types are assumed to be the same as the first engine (non-SRB) found.
  3. This is designed primarily for stock-alike engines. Mod engines that require strange fuels may have unexpected issues.

 

Powered recovery is made possible by Malkuth, of Mission Controller Extended. Malkuth graciously offered the MCE powered recovery code to me, which was used as a base for the code implemented here.

 

 

Some notes about stages burning up:

Spoiler

The chance of burning up should be 100 x 2 x [(srf_speed / DR_Velocity) - 1], which in other words is 2% per 1% that the surface speed is faster than the DR Velocity setting. As an example, if you set the DR_Velocity to 1500, then a 2000 m/s surface speed will have a 67% chance of burning up, rather than 0% at the default setting of 2000 m/s.

Adding a heat shield can reduce this chance by up to 100% (note that the chance of burning up can exceed 100%) based on how much material remains. If 50% of the heat shield material remains, then the chance of burning up reduces by 50%. 100% remaining -> 100% reduction, 10% remaining -> 10% reduction, and so on.

As an example, consider a stage going 3200 m/s at the point of "deletion" when SR kicks in. This stage has a 120% chance of burning up, meaning it will always be destroyed if it doesn't have a heatshield. Luckily, it has a heatshield attached that has 80% of the ablator left. This reduces the chance of burning up by 80%, down to 40% (120-80=40), greatly increasing the odds of the stage surviving reentry.

As of 1.6.6 for KSP 1.2.2, stages eligible for powered recovery will attempt to reduce their speed to below the minimum speed for burning up by using fuel.

 

 

PSA: Set your chutes to open at Min Pressure of 0.5 and activate/stage them with your stages!

KSP 1.0 added reentry heating (and parachute breaking) and an increased physics range (now 22.5km). If you drop a stage below ~10km it might hit the ground before you are out of physics range. Setting Min Pressure to 0.5 and activating the chutes will cause them to deploy around 4.5 km at a hopefully low enough speed. Set it higher than 0.5 if you'll be dropping them at speeds higher than 250 m/s at altitudes around 5km or less so they aren't ripped off.

eUotoha.png

 

Download: [1.4] StageRecovery 1.8.0 (2018-03-11)

Space Dock

Curse

GitHub

 

 

Some video reviews:

A very nice review covering the basic usage of StageRecovery by maxrsp

 

A review by none other than Scott Manley himself (along with the excellent FMRS by SIT89, which StageRecovery is designed to cooperate with)

 

License is GPL v3. Source is on GitHub.

Changelog:

Spoiler

1.8.0 (2018-03-11)
- Built against KSP 1.4.0. Might be backward compatible.
- Pre-recovery now fully recovers vessels and not just kerbals
- Add distance restriction to pre-recovery to prevent it from firing at the wrong time
- Recovery now fires the OnVesselRecovered event but forcibly removes the funds handling and scene changes associated with it
    - The above changes make contracts that require recovering vessels/crew work much better, but keep your timewarp down to 10x or so
- Removed explicit ScrapYard support due to the above changes not requiring it anymore
- Kerbals and Science are now recovered by default and cannot be turned off
- Use funds symbol in stock recovery messages (thanks Starwaster)

1.7.2 (06/01/2017)
- Built against KSP 1.3, but should still support KSP 1.2.2
- Added support for ScrapYard mod. Adds parts to inventory upon recovery.

1.7.1 (04/09/2017)
- Added support for RecoveryController, an improved form of compatibility between recovery mods (thanks LinuxGuruGamer!)

1.7.0 (03/18/2017)
- Added support for the updated FMRS
- Fixed bug with crew recovery that resulted in them still being marked dead
- Added option to disable kerbal pre-recovery

1.6.8 (01/29/2017)
- Fixed issue where parachutes seemingly weren't being accounted for when speeds were greater than DRMaxVelocity

1.6.7 (01/23/2017)
- Fixed issue with RealChute integration

1.6.6 (01/22/2017)
- Update to KSP 1.2.2.
- Powered recovery now tries to perform a reentry burn to reduce speed and avoid burning up.
- Kraken finds Kerbals to be less tasty when changing vessels/scenes (less randomly disappearing)
- Terminal velocity estimations centralized and can be called through API/wrapper

1.6.5 (10/20/2016)
- Update to KSP 1.2
- New estimator for stock parachutes based on physics. Not perfect, will try to improve
- No longer spams messages when the recovery errors (#32)
- Added a global recovery modifier option (#39)
- Settings now go in StageRecovery/PluginData/Config.txt
- Editor GUI now supports any IStageSeparators
- Pulled in some fixes for the Toolbar mod

Thank you linuxgurugamer, Iskie, and Kerbas-ad-astra for your PRs!

1.6.4 (05/02/2016)
- Update to KSP 1.1.2. Huge thanks to rem0230 and Cerebrate for their help!

1.6.3 (02/21/2016)
- Fix for kerbals being killed in landed vessels
- MechJeb should appear as a valid control source for landed recovery (untested)

1.6.2 (01/02/2016)
- Fix for things below 23km not being added to Recovery Queue
- Fix for ModuleAblators that don't use Ablator resource

1.6.1 (12/29/2015)
- Powered recovery should work correctly with pre-recovered Kerbals now

1.6.0 (12/21/2015)
- Hovering over Stock the SR icon in flight lets you preview the SR window
- TweakScaled parachutes now supported
- Tourists and other crew are pre-recovered while in the flight scene, preventing contract failure
- Improved the Editor Helper. Now splits the vessel into individual stages and provides velocity estimates for each stage. Will be improved after receiving feedback
- New setting to completely remove all SR buttons, accessible only through the config file
 

1.5.8 - (11/09/2015)

- Update to KSP 1.0.5

1.5.7 - (07/11/2015)

- Fixed issues with kerbal recovery causing lost levels

- Fixed compatibility issue with RSS (checking only for Kerbin)

- Added info for when a stage is lost because no pilot or probe with SAS

- Fixed up Tracking Station related things a bit. Powered recovery should work now and you can terminate a flight and get things recovered as long as its in the atmosphere at the time (including "orbiting" vessels)

1.5.6 - (05/15/2015)

- Non-parachuted stages now have a fixed Vt of 200 m/s

- Powered recovery should work properly now. Requires 300m/s of dV to work.

- Added OnRecoveryProcessingStart and OnRecoveryProcessingFinish events to API, for Kerbal Konstructs support. Fire when first starting recovery code (after determining viability for recovery, but before Vt calculations) and at the end of recovery code (doesn't include information about recovery, just for cleaning up)

- Support for RealChuteLite in FAR

- Hopefully fixed issues with ridiculous distances from KSC. If not, now logging lat/lon of stage and KSC, to help debug.

1.5.5 - (05/02/2015)

- Updated to KSP 1.0.2

- Fixed calculation of Vt for stages. Not 100% accurate, but fairly close

- Added option to choose which Toolbar to use (when Toolbar Mod is installed)

- Switched to KCT's code for calculating building levels, since that worked in 0.90

1.5.4 - (04/28/2015)

- Updated to KSP 1.0

- Tie into the stock upgrade system.

- Tracking Center upgrades improve distance based returns

- Pilot kerbals or probes with SAS are needed for powered recovery

- Added FMRS support. The two shouldn't try to recover the same things now and should play nicely together!

- Added colors in recovery messages

- A bit of Flight GUI rework to make it easier to use, take less screen space, and generally be better.

- Deadly Reentry support moved to use Stock system. Doesn't scale with Stock setting yet, but if Stock is set to 0% then SR won't burn things up.

1.5.3 - (12/22/2014)

- Fixed issue with losing experience on recovery. Kerbals now gain experience as appropriate for landing on Kerbin.

1.5.2.1 - (12/15/2014)

- Made min TWR setting functional

- Fixed issue with calculating parachute drag values that caused parachute recovery to not function.

1.5.2 - (12/15/2014)

- Compatibility update for KSP 0.90

- Automatic recovery of launch clamps when they are unloaded.

- Right clicking on a stage in the flight GUI will now delete it.

- Added indicator to flight GUI showing which stage is selected.

- Several bug fixes.

- Contains a bug where kerbals will lose experience if they are in the craft when it's "recovered". Will be fixed soon.

1.5.1 - (10/07/2014)

- Compatibility update for KSP 0.25

NOTE: Does not include any changes due to strategies, so you won't get extra recovery factor for the one (yet).

1.5.0 - (09/06/2014)

- Added Ignore List. Any stages made up entirely of parts in the ignore list won't attempt to be recovered.

- Reworked the flight-GUI a bit. Made it smaller, draggable, and minimizes to just the list until a stage is selected. Hopefully even less intrusive now.

- Found a general solution to the fuel use problem for powered recovery. Can now handle engines that require any fuel amounts without being CPU intensive.

- Forced no checking on scene change. Should fix erroneous messages appearing on scene change for some users.

1.4.3 - (08/30/2014)

- Should have been 0.01 pressure. I'm sorry about the second update! :(

1.4.2 - (08/30/2014)

- Changed recovery code to check for altitudes above 100 meters and pressures above 0.1 instead of just searching for below 35km.

- Fixed issue with displaying orbital velocity vector instead of speed in Flight GUI.

- Was returning funds even for stages that had burned up, fixed now.

1.4.1 - (08/22/2014)

- Added error catching to recovery code. Even if there's a bug, it shouldn't break your game now.

- Removed a bunch of debug code from the Powered Recovery code.

- Remembered to include the license in the download.

1.4.0 - (08/18/2014)

- Powered recovery. Controlled stages can be landed with their engines. Requirements will be listed in a separate section.

- Editor helper now shows results for current fuel levels and with empty fuel levels.

- Several small improvements to flight GUI (wording and such).

- Several bug fixes for Vt calculation and with stock parachutes and crashes.

1.3.0 - (08/05/2014)

- New Flight GUI which presents all Recovered and Destroyed Stages since Flight was started in a convenient, easy to use dialog.

- Editor Helper: Click the SR icon to see what the terminal velocity, recovery status, and percent recovered will be for the current vessel (including current fuel)

- Fixed an issue with calculation of terminal velocities. I was missing a square root.

1.2.1 - (08/02/2014)

- Fixed small issue with recovery when below the low cutoff velocity

- Hopefully averted issue with negative refunds (minimum per part should be zero)

1.2.0 - (08/02/2014)

- Added Varaible Recovery Rate model where the recovery percentage is determined by the velocity between two cutoffs. A more detailed explanation can be found here https://github.com/magico13/StageRecovery/issues/1

- Updated the API, see explanation later in the OP.

- Optional Blizzy toolbar support

- Non-ablative shielding counts as 400 ablative shielding instead of decreasing the burnChance to 0.

1.1.4 - (07/28/2014)

- Added in game settings menu (space center scene)

- Changed recovery code to calculate exclusively in m/s. Cutoff velocity is configurable between 2 and 12 m/s

- Added EXPERIMENTAL Deadly Reentry support. It's based on velocity percentages above the DeadlyReentryMaxVelocity. 2% chance of failure per 1% speed exceeded. Each 1% of heat shield removes 1% chance of failure.

- Changed recovery of kerbals and science to enabled by default.

1.1.3 - (07/22/2014) - Added API. Made it so Kerballed command pods will also increase recovery value to 100% of Stock.

1.1.2 - (07/20/2014) - Fixed a small issue that would cause recovery to fail if multiple identical parts were on the same recovered vessel.

1.1.1 - (07/19/2014) - Added science recovery, 100% if probe core attached, and messages.

1.1.0 - (07/18/2014) - Added ability to recover Kerbals (disabled by default). Limited recovery modifier to between 0 and 1. Updated to work with latest RealChutes.

1.0.1 - (07/18/2014) - If you make something configurable, you should make sure it actually does something. Derp.

1.0 - (07/18/2014) - Initial release

 

 

 

Mods currently using the API (notify me if you want to be added to this list):

Kerbal Construction Time

Kerbal Konstructs

 

Support me on Patreon!

Support me on Patreon!

 

If you're feeling particularly adventurous, the latest StageRecovery builds are available on the development thread. These will likely have bugs, but will also incorporate the latest fixes and newest features.

Edited by magico13
1.8
Link to comment
Share on other sites

I stupidly forgot to make the configurable recovery rate actually do anything in the code, so you may want to redownload it. I just fixed that. If you're fine with 75% recovery, then you don't really need to :P

I should probably watch his 0.24 videos at some point. One of my users of KCT suggested I split this off from it, since KCT has had booster recovery since February.

Link to comment
Share on other sites

Wow, that's fast!

Scott Manley predicted it, magico13 did it. That sure was fast! Dowloading now

Not sure if he predicted it... Mission Controller mod had this capability for a very long time.

Link to comment
Share on other sites

Not sure if he predicted it... Mission Controller mod had this capability for a very long time.

Ah, didn't know about this one. But i meant dedicated mods for recovery, now that its a core mechanic.

Link to comment
Share on other sites

Not sure if he predicted it... Mission Controller mod had this capability for a very long time.

That it did, Malkuth and I worked together to refine each other's recovery procedures. I was the one who originally wrote the Real Chutes based recovery that Malkuth modified for MCE, and I based my original recovery procedure on MCE's. The first incarnation of my recovery code was published on February 15th, so it definitely predates anything Scott Manley predicted recently :D

Link to comment
Share on other sites

Teeny question: Wat if there is science on the stages? Does it go caput?

Yes, this does not recover science or kerbals. It's not meant to be a substitute for traditional landings when dealing with important things (science and kerbals) that should be landed manually. I may add that in later, but I feel that's a little too OP since they're delicate enough to warrant manual landings.

Link to comment
Share on other sites

Yes, this does not recover science or kerbals. It's not meant to be a substitute for traditional landings when dealing with important things (science and kerbals) that should be landed manually. I may add that in later, but I feel that's a little too OP since they're delicate enough to warrant manual landings.

Stick it in as a config option.

Would be nice to be able to use this and EPL+kethane/ORS to build disposable science or resource return ships I can just chuck at kerbin from orbit and not worry about as I work on transfers and whatnot.

Link to comment
Share on other sites

As awesome of an update 0.24 is, and i absolutely love it, i expected this or something similar to be stock and i kindof frowned when it wasn't. I haven't played enough to see wether or not the funds make up for it, but as in the real world, the part of my spaceship that actually does a mission and returns is often only a fraction of what leaves the launchpad.

Great mod, downloading soon. Thanks ^-^. Quick, too ♫

Link to comment
Share on other sites

So how does it deal with re-entry? Will a tank dropped while sub-orbital in space burn up? Because I'd like that to be a thing, at least if DRE is installed.

Looks awesome otherwise, and I can't wait for KCT to be updated.

Link to comment
Share on other sites

So how does it deal with re-entry? Will a tank dropped while sub-orbital in space burn up? Because I'd like that to be a thing, at least if DRE is installed.

It doesn't simulate any physics, it just looks for the vessel being destroyed in atmosphere so it won't burn up if dropped from space. However, if the periapsis is above 0 I believe the ship/debris is no longer considered Sub-Orbital and is instead In-Orbit, which means it won't get recovered by this despite being destroyed by the atmosphere. I generally consider this fair enough, since anything not going fast enough to have a positive periaspsis could possibly survive reentry. It also comes down to personal preference and responsibility. With my designs, if a stage makes it all the way into space I generally don't put parachutes on it and let it get destroyed, but boosters that only get up to 35km or so are fair game.

Link to comment
Share on other sites

It doesn't simulate any physics, it just looks for the vessel being destroyed in atmosphere so it won't burn up if dropped from space. However, if the periapsis is above 0 I believe the ship/debris is no longer considered Sub-Orbital and is instead In-Orbit, which means it won't get recovered by this despite being destroyed by the atmosphere. I generally consider this fair enough, since anything not going fast enough to have a positive periaspsis could possibly survive reentry. It also comes down to personal preference and responsibility. With my designs, if a stage makes it all the way into space I generally don't put parachutes on it and let it get destroyed, but boosters that only get up to 35km or so are fair game.

I consider that fair too, since the heavy launch stages would be in a sub-orbital trajectory. If it is not, your rocket is over-engineered lol

Link to comment
Share on other sites

It doesn't simulate any physics, it just looks for the vessel being destroyed in atmosphere so it won't burn up if dropped from space. However, if the periapsis is above 0 I believe the ship/debris is no longer considered Sub-Orbital and is instead In-Orbit, which means it won't get recovered by this despite being destroyed by the atmosphere. I generally consider this fair enough, since anything not going fast enough to have a positive periaspsis could possibly survive reentry. It also comes down to personal preference and responsibility. With my designs, if a stage makes it all the way into space I generally don't put parachutes on it and let it get destroyed, but boosters that only get up to 35km or so are fair game.

I'm having a hard time parsing that, let me see if I got it right. You're saying the mod triggers when a part has been auto-destroyed by being too low in the atmosphere, right? And it can tell what the periapsis was when the part was destroyed? And if so, it gives you credit if the part's periapsis at the time of auto-destruction was negative (meaning it would have hit the ground) and assume that if the periapsis was above the ground that the part was going too fast to survive re-entry.

I suppose that's fine, and it'll hold me over until I get around to extending the physics distance and adding some kOS scripts to land and recover them manually.

Link to comment
Share on other sites

I think I have found a bug. If you go to the tracking station, nothing shows up on the list of objects and the button to leave the tracking station does nothing. I confirmed that it was this mod because after removing it, the bug went away. I am running 32-bit ksp on windows 8 64-bit. The mods I am running are kethane, Mechjeb 2, DRE, FAR, KJR, Navyfish's docking, precisenode, Procedural fairings, TAC life support, and kerbal alarm clock. I am going to reinstall the mod and post some screenshots of the bug.

Javascript is disabled. View full album
Edited by Redjoker
Add screenshots
Link to comment
Share on other sites

I'm having a hard time parsing that, let me see if I got it right. You're saying the mod triggers when a part has been auto-destroyed by being too low in the atmosphere, right? And it can tell what the periapsis was when the part was destroyed? And if so, it gives you credit if the part's periapsis at the time of auto-destruction was negative (meaning it would have hit the ground) and assume that if the periapsis was above the ground that the part was going too fast to survive re-entry.

I suppose that's fine, and it'll hold me over until I get around to extending the physics distance and adding some kOS scripts to land and recover them manually.

Kind of. It looks to see what state the vessel is in and if it's sub-orbital or flying it will continue trying to recover it. It begins this check when the vessel is destroyed, in this case by being unloaded within the atmosphere. If the periapsis is above 0, then it is orbital, not sub-orbital and so it won't be recovered if it's destroyed.

hmm how is this any different from DebRefund?

Well, that mod looks cleaner but we both wrote ours independently at roughly the same time :P I do want to integrate with the stock toolbar and message system, I just haven't had time to figure that out with trying to update KCT and also trying to get a new YouTube video out today. This mod is essentially stripped right out of KCT and changed to be made functional on its own, while DebRefund appears to have been written specifically for the 0.24 update. My code was originally written for total part recovery for putting parts in a part inventory, so DebRefund's form of partial recovery is more advanced than the flat rate form I use.

I do plan on adding config options for science and kerbals. Also, beware of the new Real Chute update. I need to verify that it's working properly, as my testers are saying that it's bugged with my KCT update, meaning it could be bugged here.

Link to comment
Share on other sites

So I just threw another update onto the front page. This should work now with the new version of real chutes and I also added the ability to recover Kerbals from stages. I'm working on getting science to work but I keep running into an issue where the subject value is NaN and so no science is returned. If you were having issues before, try this version out and see if they're fixed an let me know if they aren't. Thanks :)

Link to comment
Share on other sites

In my opinion there is no reason for DebRefund and StageRecovery to compete, so I'm going to suggest that people use DebRefund as the UI integration and gameplay mechanics are better than what I'm offering here. It also means I can focus more directly on KCT, which has yet to have a 0.24 release. Vendan and I are in talks of getting compatibility between DebRefund and KCT for recovery mechanics.

DebRefund: http://forum.kerbalspaceprogram.com/threads/86691-0-24-DebRefund-v1-0-4

If for some reason you really want to use this instead, let me know. Otherwise, KCT will have virtually identical recovery mechanics when it releases. Kerbal and Science recovery will not be supported in KCT, however.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...