Jump to content

[1.12.x] StageRecovery - Recover Funds+ from Dropped Stages


linuxgurugamer

Recommended Posts

Gaaaahhhhhh!

This is soooooo wieerrrddd.

But I figured it out.  It's one of those obvious after the fact things

The problem was here:

 Log.Info("[SR] RecoveryController registration success: " + RecoveryControllerWrapper.RegisterModWithRecoveryController("StageRecovery"));

which works fine in debug mode, because the Log.Info is enabled when compiled with debug mode.

however, because of this:


        [ConditionalAttribute("DEBUG")]
        public static void Info(String msg)
        {
            if (IsLogable(LEVEL.INFO))
            {
                UnityEngine.Debug.Log(PREFIX + msg);
            }
        }

it does NOT get compiled at runtime.  I put the call to register the mod with the recovery controller in a line which never gets executed when compiled for release.

The correct code is this:

                var s = RecoveryControllerWrapper.RegisterModWithRecoveryController("StageRecovery");
                Log.Info("[SR] RecoveryController registration success: " + s);

I use the Log class to make debug lines go away in release code, to help avoid log spam.

The original code from Magico13 was this:

 Debug.Log("[SR] RecoveryController registration success: " + RecoveryControllerWrapper.RegisterMod("StageRecovery"));

So the problem is only with StageRecovery, I'll have an update out soon.

 

 

New release, 1.9.0.7

  • Fixed registration with the RecoveryController by moving initialization OUT of the Log.Info line
Link to comment
Share on other sites

  • 2 weeks later...
28 minutes ago, somepersondunno said:

 Any clue of why?

Because the .version file is not updated (at least in the download, the online version file is up to date). You can ignore it or, if you are annoyed by the message, edit the file to match the online version:

{
  "NAME": "StageRecovery",
  "URL": "http://ksp.spacetux.net/avc/StageRecovery",
  "DOWNLOAD": "https://forum.kerbalspaceprogram.com/index.php?/topic/179306-151-stagerecovery",
  "VERSION": {
    "MAJOR": 1,
    "MINOR": 9,
    "PATCH": 0,
    "BUILD": 7
  },
  "KSP_VERSION": {
    "MAJOR": 1,
    "MINOR": 5,
    "PATCH": 1
  },
  "KSP_VERSION_MIN": {
    "MAJOR": 1,
    "MINOR": 5,
    "PATCH": 1
  }
}

 

Link to comment
Share on other sites

4 hours ago, 4x4cheesecake said:

Because the .version file is not updated (at least in the download, the online version file is up to date). You can ignore it or, if you are annoyed by the message, edit the file to match the online version:


{
  "NAME": "StageRecovery",
  "URL": "http://ksp.spacetux.net/avc/StageRecovery",
  "DOWNLOAD": "https://forum.kerbalspaceprogram.com/index.php?/topic/179306-151-stagerecovery",
  "VERSION": {
    "MAJOR": 1,
    "MINOR": 9,
    "PATCH": 0,
    "BUILD": 7
  },
  "KSP_VERSION": {
    "MAJOR": 1,
    "MINOR": 5,
    "PATCH": 1
  },
  "KSP_VERSION_MIN": {
    "MAJOR": 1,
    "MINOR": 5,
    "PATCH": 1
  }
}

 

Also, in 1.6.1, the mod doesn't seem to activate. Is there an up to date version that'll actually function? Not to poke a bear, but I'm having some issues.

Link to comment
Share on other sites

1 minute ago, somepersondunno said:

Also, in 1.6.1, the mod doesn't seem to activate. Is there an up to date version that'll actually function? Not to poke a bear, but I'm having some issues.

Do you mind to add some details to your issue?

Do you have FMRS and Recovery Controller installed as well or just Stage Recovery? It's fine to run just Stage Recovery but if you run the others as well, you have to choose between both mods, which one is actually supposed to handle the dropped stages.
Keep in mind that your dropped stage need to be controllable and some chutes or some fuel left to try a powered landing. Also, Stage Recovery kicks in as soon as the game would just remove the part from the game, which usually happens as soon as the part is outside of the physics range and below a certain altitude (IIRC 23km on Kerbin). Only, if all requirements are met, Stage Recovery can try to recovery your stage.

Link to comment
Share on other sites

13 minutes ago, 4x4cheesecake said:

Do you mind to add some details to your issue?

Do you have FMRS and Recovery Controller installed as well or just Stage Recovery? It's fine to run just Stage Recovery but if you run the others as well, you have to choose between both mods, which one is actually supposed to handle the dropped stages.
Keep in mind that your dropped stage need to be controllable and some chutes or some fuel left to try a powered landing. Also, Stage Recovery kicks in as soon as the game would just remove the part from the game, which usually happens as soon as the part is outside of the physics range and below a certain altitude (IIRC 23km on Kerbin). Only, if all requirements are met, Stage Recovery can try to recovery your stage.

It has one of those 'inform me when this mod updates' things in the loading screen but the actual icon for SR on the toolbar doesn't show up at all. Should I try a clean install, or is it the download's fault? And I don't have any of those other mods.

Edited by somepersondunno
spelling
Link to comment
Share on other sites

7 minutes ago, somepersondunno said:

It has one of those 'inform me when this mod updates' things in the loading screen

Like this?

Spoiler

G1Xr8Tl.png

(They all work fine though ;) )

This should not appear for Stage Recovery and it doesn't for me and I have it installed. Are you sure you got the latest version of the mod?

Link to comment
Share on other sites

10 minutes ago, 4x4cheesecake said:

snip

This is what my VAB looks like, ATM.

I got my install from Spacedock. I'm running:

KER, Mechjeb, Stockalike Station Parts, TACLS, KIS, and KAC.

Note that I don't have the "stage recovery icon" thing on my toolbar, despite installing it.

 

Edited by somepersondunno
spelling agin
Link to comment
Share on other sites

1 hour ago, Loren Pechtel said:

It's possible this has been fixed but given how long it's been there I doubt it:

When doing a propulsive landing it tells you how much fuel it burned doing it, but it doesn't tell you how much was left in the tanks afterwards.

Fixed?  That implies something is broken.

 

Link to comment
Share on other sites

2 hours ago, Loren Pechtel said:

It's possible this has been fixed but given how long it's been there I doubt it:

When doing a propulsive landing it tells you how much fuel it burned doing it, but it doesn't tell you how much was left in the tanks afterwards.

I am not positive (its been too long since I really looked at the numbers), but I believe the parts breakdown of what parts landed safely (and the refunded part value), also include what fuel was refunded. 

Link to comment
Share on other sites

20 minutes ago, BlackHat said:

I am not positive (its been too long since I really looked at the numbers), but I believe the parts breakdown of what parts landed safely (and the refunded part value), also include what fuel was refunded. 

I'm finding the parts that were recovered but no fuel listed.  The value of the fuel is listed, not the amount.  I do feel like an older version did list the amount of fuel.

1 hour ago, linuxgurugamer said:

Fixed?  That implies something is broken.

 

It's a very useful piece of information and trivial to display.  I consider it's absence to be broken.

Link to comment
Share on other sites

It never showed the amount of fuel, just the value.

4 hours ago, Loren Pechtel said:

It's a very useful piece of information and trivial to display.

Speaks someone who doesn't know coding.  Yes, it's very useful information.  Trivial  it's not.  

Let me explain a little bit:

Recovered stages are, by definition, not in physics range.

Let me explain a bit:

First, the mod uses a stock KSP function to get the values.  As it turns out, it does NOT subtract the amount of fuel which would have burned up, so the value of what you see is actually too high.  Consider THAT a bug.

Second, even if the KSP had the ability to return the amount of fuel remaining, since the fuel is not actually burned it would still be inaccurate

I took a look at the code to answer your question.  While it's doable with a little work, it's not 5 minutes work.  Now, do you want to know the amount of oxidizer, or the amount of liquid fuel remaining?  What about RealFuels, which uses different types of fuel?  What about jet-assisted landings?

The mod does, in fact, have some of this information available internally, but to get it available in the output is going to take a little while

 

Link to comment
Share on other sites

4 hours ago, linuxgurugamer said:

It never showed the amount of fuel, just the value.

Speaks someone who doesn't know coding.  Yes, it's very useful information.  Trivial  it's not.  

Let me explain a little bit:

Recovered stages are, by definition, not in physics range.

Let me explain a bit:

First, the mod uses a stock KSP function to get the values.  As it turns out, it does NOT subtract the amount of fuel which would have burned up, so the value of what you see is actually too high.  Consider THAT a bug.

Second, even if the KSP had the ability to return the amount of fuel remaining, since the fuel is not actually burned it would still be inaccurate

I took a look at the code to answer your question.  While it's doable with a little work, it's not 5 minutes work.  Now, do you want to know the amount of oxidizer, or the amount of liquid fuel remaining?  What about RealFuels, which uses different types of fuel?  What about jet-assisted landings?

The mod does, in fact, have some of this information available internally, but to get it available in the output is going to take a little while

 

Actually, I do know coding.

If the mod didn't already know the fuel left it couldn't figure out of there was enough to do the landing burn.  While in theory it could be working with delta-v rather than units of fuel it is reporting the amount burned in units.  Since the fuel is almost certainly in a locked tank the game core isn't going to tell the truth about it, the mod must be doing it.

Link to comment
Share on other sites

6 hours ago, Loren Pechtel said:

Actually, I do know coding.

If the mod didn't already know the fuel left it couldn't figure out of there was enough to do the landing burn.  While in theory it could be working with delta-v rather than units of fuel it is reporting the amount burned in units.  Since the fuel is almost certainly in a locked tank the game core isn't going to tell the truth about it, the mod must be doing it.

 

As I said: 

6 hours ago, Loren Pechtel said:

The mod does, in fact, have some of this information available internally, but to get it available in the output is going to take a little while

but, it's not available in an easy-to-use format.  When it was written, it was not written with the idea of returning this information (I don't know why), so it was rather buried.  I'm working on it.

I wish I had a nickel for every time someone say the works "It should be trivial to add.......".  Without looking at the code, even if you do know coding, you have no idea what you are talking about

Link to comment
Share on other sites

I really like this mod! I just installed it yesterday but I wish I had been using it all along.

I wanted to know in advance if I had added enough parachutes, rather than hoping for a pleasant surprise when I got out of physics range.  So I looked through the source code, did some math, and did some in-game experimentation.

The code uses the standard terminal velocity formula, v = ROOT[(2 m g)/(rho A Cd)].  The g used in the code is 9.81m/s² precisely, and rho at sea level in stock KSP is about 1.225 kg/m3, but the area and coefficient of drag for the stock parachutes were not readily available (not surprisingly, the values shown in the VAB and the parts cfg files did not align with expectations). The StageRecovery source code calculates it from the drag cubes, which is not something I am equipped to handle, so I conducted a series of launches varying numbers of parachutes and mass, and wrote down the results.

Long story short, these are the calculated Area × coefficient of drag values (in m²) for the five stock parachutes. (The only chute tested more than once was the Mk2-R (n=9, stdev=0.3%).)

102    Mk16 Parachute
411.6  Mk2-R Radial-Mount Parachute
612    Mk16-XL Parachute
 14    Mk12-R Radial-Mount Drogue
  9.4  Mk25 Parachute (node-mounted drogue)

It is also worth noting that TweakScale behaves as expected; a parachute scaled to 200% gives 4× the area of the base model.

With that data and the formula, you can calculate the amount of mass you can land under your recovery velocity threshold with a given number of parachutes. Holding velocity constant, mass and area are proportionately-related in the formula, and it can be calculated that:

1 Mk2-R is needed per 1.5447 Mg of mass (not counting parachute mass) to be recovered at 8.0m/s

Link to comment
Share on other sites

  • 2 weeks later...

Hello!

Thanks @linuxgurugamer for your hard work in supporting our community through all your amazing modding efforts!

I was hoping somebody could help me with a situation I am experiencing - Trying to have StageRecovery to recover a SpaceX style booster which is bringing payload to orbit then boosting retrograde to lower periapsis just over KSP around 20KM.

I have tested my ship and It seems to work fine when I remove the three SRB's which also user stage recovery, although they drop quite early in the initial ascent.

When I try this with my ship's final profile, I get this error:
 

[LOG 16:45:55.456] [F: 200547]: Vessel MSE - MARSUPIAL DELTA-R Ship was on-rails at 1.0 kPa pressure and was destroyed.
[LOG 16:45:55.456] -INFO- Tac.LifeSupportController[FF504430][5944.94]: Vessel Destroyed [00e0668d-3cb7-4d5c-95cc-8a57c4ce2f7b] MSE - MARSUPIAL DELTA-R Ship
[ERR 16:45:55.526] Exception handling event onVesselWillDestroy in class StageRecovery:System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[System.String,System.Double].Add (System.String key, Double value) [0x00000] in <filename unknown>:0
  at StageRecovery.RecoveryItem.ReduceSpeed_Engines (Double initialSpeed, Double targetSpeed) [0x00000] in <filename unknown>:0
  at StageRecovery.RecoveryItem.TryPoweredRecovery () [0x00000] in <filename unknown>:0
  at StageRecovery.RecoveryItem.Process (Boolean preRecover) [0x00000] in <filename unknown>:0
  at StageRecovery.StageRecovery.RecoverVessel (.Vessel v, Boolean preRecovery) [0x00000] in <filename unknown>:0
  at StageRecovery.StageRecovery.VesselDestroyEvent (.Vessel v) [0x00000] in <filename unknown>:0
  at EventData`1[Vessel].Fire (.Vessel data) [0x00000] in <filename unknown>:0

[EXC 16:45:55.527] ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,System.Double].Add (System.String key, Double value)
    StageRecovery.RecoveryItem.ReduceSpeed_Engines (Double initialSpeed, Double targetSpeed)
    StageRecovery.RecoveryItem.TryPoweredRecovery ()
    StageRecovery.RecoveryItem.Process (Boolean preRecover)
    StageRecovery.StageRecovery.RecoverVessel (.Vessel v, Boolean preRecovery)
    StageRecovery.StageRecovery.VesselDestroyEvent (.Vessel v)
    EventData`1[Vessel].Fire (.Vessel data)
    UnityEngine.Debug:LogException(Exception)
    EventData`1:Fire(Vessel)
    Vessel:Die()
    Vessel:CheckKill()
    VesselPrecalculate:MainPhysics(Boolean)
    ModularFI.ModularVesselPrecalculate:MainPhysics(Boolean)
    VesselPrecalculate:FixedUpdate()
    ModularFI.ModularVesselPrecalculate:TimedFixedUpdate()
    TimingPre:FixedUpdate()

If anyone could point me to a solution I would be very grateful!

I'll keep troubleshooting and update here if I end up solving it myself. I wondered if it had to do with leaving two active decouplers set to StageRecovery via RecoveryController, but I have removed the extra leaving a relatively simple booster consisting of a few fuel tanks, an engine, a probe core, rcs, and parachutes.

 

Thanks in advance!

Link to comment
Share on other sites

52 minutes ago, Jezzick said:

Hello!

Thanks @linuxgurugamer for your hard work in supporting our community through all your amazing modding efforts!

I was hoping somebody could help me with a situation I am experiencing - Trying to have StageRecovery to recover a SpaceX style booster which is bringing payload to orbit then boosting retrograde to lower periapsis just over KSP around 20KM.

I have tested my ship and It seems to work fine when I remove the three SRB's which also user stage recovery, although they drop quite early in the initial ascent.

When I try this with my ship's final profile, I get this error:
 


 

If anyone could point me to a solution I would be very grateful!

I'll keep troubleshooting and update here if I end up solving it myself. I wondered if it had to do with leaving two active decouplers set to StageRecovery via RecoveryController, but I have removed the extra leaving a relatively simple booster consisting of a few fuel tanks, an engine, a probe core, rcs, and parachutes.

 

Thanks in advance!

First, the complete log file would be helpful.

Second, correct me if I'm wrong, but if you launch without the SRBs, it work ok?

Finally, a copy of the craft file for testing would also be helpfull

Link to comment
Share on other sites

I'm running a test again to confirm that removing the SRB's fixes the problem. I Removed the fuel from Stage 2 so that the ascent and descent profile more closely match what it was doing when the SRB's were attached (Plenty more Delta V)

Will let you know the end result.

Craft File:

https://drive.google.com/open?id=1vnH83gf6rgcQyhvbzAtYRVlI-1sVxZdy

Log:

https://drive.google.com/open?id=1Mp_rDh00NeVexVyTwxPAtWrAWooF27vA

Thank you for replying so quickly and with such helpful enthusiasm!

 

(EDIT: Damn. Same error after testing the rocket w/o SRB's. So it is something about my ascent profile being different that could be causing it to fail, where it worked before. I'll keep trying to see under what conditions the recovery works on the current rocket, without SRB's for simplicity. Mission profile is Precisely:

Using Gravity Turn Mod, ascend to 80KM, Circularize w/ Mechjeb, separation, w/ booseter: create node approx at apoapsis, lowering periapsis to 23KM over KSC, jump back to Payload, time warp 5 or 10X until vessel destruction, at this point there is no message regarding the boosters fate, it is just removed from the game.)

Edited by Jezzick
Update w/ new test results.
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

×
×
  • Create New...