Jump to content

Suicide Burn mod Development - Updated 5/12 - Almost BETA time


Recommended Posts

20 minutes ago, Pand5461 said:

I think what was meant is the reverse - what if the engine can't go below 79% throttle?

I meant to type 70% (think that is what Merlin 1D does at lowest). :wink: But yet, that's what I was getting at.

Link to comment
Share on other sites

17 minutes ago, tater said:

I meant to type 70% (think that is what Merlin 1D does at lowest). :wink: But yet, that's what I was getting at.

But on the SpaceX vessels, they are only using 3 of 9 engines, which really means that your 70% would really be about 30% of all engines, which is the way KSP works.

Link to comment
Share on other sites

1 hour ago, linuxgurugamer said:

Ah.  Well, in that case, the engine would do lots of stops and starts near the end

But... Throttle is probably PID-controlled? So, it's possible to calculating suicide burn not for full thrust but for 0.9 thrust and use PID to keep the ship always at the suicide burn distance until the touchdown. This is probably how it's done IRL.

Some (not exactly) simple math

For a vertical descent, if we neglect atmospheric drag, time of suicide burn is (approximately, but suprisingly accurately)

ts = (g - adry + sqrt( (g - adry)2 - 2*V*adry2/(Isp*g0) ) ) * (Isp*g0)/adry2

g being the free fall acceleration, adry the acceleration of rocket at full thrust at touchdown (to know that before starting the burn, you of course going to need some guesstimation), Isp the specific impulse, g0 = 9.80665 m/s2, V the vertical speed.

Distance travelled in that time is

hs = -V*ts - (adry - g)*ts2/2 - adry2/(Isp*g0)*ts3 / 6

So, at vertical part of burn you can assume "nominal thrust" as (maxT + minT)/2, calculate ts and hs for suicide burn at this throttle level, and then keep

actualthrottle = nominalthrottle + PID( h - hs(V) ), where h is the actual height above the ground.

Edited by Pand5461
changed formula to reduce ambiguity in reading
Link to comment
Share on other sites

Hmmm, i'll have to compare those to what I'm getting.  I calculate it continously, becasue landing in an atmosphere changes things.

But, your formulas look to be extremely helpful. 

And, I need to take horizontal velocity into account as well.  If it was only vertical, I'd be done by now

3 minutes ago, Pand5461 said:

Throttle is probably PID-controlled

PID???

Link to comment
Share on other sites

1 minute ago, linuxgurugamer said:

PID???

Proportional-Integral-Derivative control.

In this case, Integral part won't be needed, I think, so it will be just PD-controller

So, PD(x) = KP*( x(t) - x0(t) ) + KD* d( x(t) - x0(t) )/dt,

where x is the actual value of signal, x0 is what you wanted the signal to be.

For those who lives in a discrete time (hint: kerbals do) that changes to

PD(x) = KP*Δ(tnow) + KD* (Δ(tnow) - Δ(tprev) ) / ( tnow - tprev),

where Δ(t) is short for ( x(t) - x0(t) ), tnow is current time, tprev is the time of previous calculation of Δ(t).

So, in the above case X is height, X0 is calculated hs, and KP and KD must be negative numbers (need to throttle up when ship is too low, and throttle up even harder if it goes increasingly below the right height).

Link to comment
Share on other sites

There are people like @Boris-Barboris who say that PID controllers are from our Grandparents time, and Neural Nets are all the Rage nowadays :wink: Those are also implemented very nicely in AtmosphereAutopilot if you want to take a look.

About the whole "horizontal velocity component", I tried to do some research and I posted some of my results over here:

tl; dr: It's not as easy as it looks, and you'll probably have to do a numeric simulation because there are no formulas. But then again, I would love to be proven wrong. That's why I'm very very curious by now about your implementation :wink:

Edited by Kobymaru
Link to comment
Share on other sites

@Pand5461 @Kobymaru Well you seemto have some background on that lol. 

However, why go so complicated on the throttle setting? You don't need to make fangy things such as an PID controller (well that's not really famcy ok) or a neural net, a simple linear equation should really be sufficient there (like burn altitude / actual altitude) or so. 

Also that with the horizontal movement thing was where I finally gave up on my code. It just got way too frustrated because I couldn't get any formulas to return some vaguely accurat results. I actually started to work getting that all numerically solved but it really took ages so it was not really appropriate to use lolz. I'll have a look at what you summed up there however.

Link to comment
Share on other sites

5 minutes ago, Kobymaru said:

There are people like @Boris-Barboris who say that PID controllers are from our Grandparents time, and Neural Nets are all the Rage nowadays :wink: Those are also implemented very nicely in AtmosphereAutopilot if you want to take a look.

PIDs are old, but well tested tools. They do their job, provided they are tuned. Tuning methods are well researched for linear systems, wich have some things to share with KSP cases. They can be manually tuned on sight, wich is a plus for maintance. Jack of all trades, master of none. Mindless, simple, werks, will work and be used decades later.

Neural nets are last resort for control. Their domain lies elswhere, on problems too complex to analyze. Not only flight is well researched problem, it is also a relatively easy one. AA could use them twice during it's lifespan, twice they were outperfomed thanks to human insight on the problem itself. There are no neural networks at work in release AA code.

Link to comment
Share on other sites

@Kobymaru, for a one-dimensional problem, NN solution is overkill (also, ever since I got familiar with the outputs of natural NNs, a.k.a. brains, I tend not to trust even artificial ones).

@Kartoffelkuchen, a proportional controller could be enough but that's KSP, people like to over-engineer things here. (In fact, discrete-time P-controller may get unstable in cases when continuous-time one is stable, that's why I suggest adding the derivative term).

Link to comment
Share on other sites

Wow, lots of good answers.

Let me answer one question  right now: I have found that pointing retrograde will do a very nice job of cancelling the horizontal velocity.  My calculations for that at merely to calculate where, along the horizontal trajectory, will the target altitude be met.

Link to comment
Share on other sites

 

11 hours ago, Boris-Barboris said:

There are no neural networks at work in release AA code.

Sorry about that, I saw some in your code and just assumed they are the reason why AA works so well.

Link to comment
Share on other sites

On 5/15/2017 at 3:19 PM, Pand5461 said:

Some (not exactly) simple math

For a vertical descent, if we neglect atmospheric drag, time of suicide burn is (approximately, but suprisingly accurately)

ts = (g - adry + sqrt( (g - adry)2 - 2*V*adry2/(Isp*g0) ) ) * (Isp*g0)/adry2

g being the free fall acceleration, adry the acceleration of rocket at full thrust at touchdown (to know that before starting the burn, you of course going to need some guesstimation), Isp the specific impulse, g0 = 9.80665 m/s2, V the vertical speed.

Distance travelled in that time is

hs = -V*ts - (adry - g)*ts2/2 - adry2/(Isp*g0)*ts3 / 6

So, at vertical part of burn you can assume "nominal thrust" as (maxT + minT)/2, calculate ts and hs for suicide burn at this throttle level, and then keep

actualthrottle = nominalthrottle + PID( h - hs(V) ), where h is the actual height above the ground.

Some questions:

What's the difference between g and  g0 , when near the ground?

For V, KSP treats descending speed as a negative number, should this be the absolute value of V?  I see a -V there.

 

Link to comment
Share on other sites

On 5/15/2017 at 3:19 PM, Pand5461 said:

For a vertical descent, if we neglect atmospheric drag, time of suicide burn is (approximately, but suprisingly accurately)

ts = (g - adry + sqrt( (g - adry)2 - 2*V*adry2/(Isp*g0) ) ) * (Isp*g0)/adry2

g being the free fall acceleration, adry the acceleration of rocket at full thrust at touchdown (to know that before starting the burn, you of course going to need some guesstimation), Isp the specific impulse, g0 = 9.80665 m/s2, V the vertical speed.

Did you leave something out?  You have the ISP there, but where is the mass of the vessel?

I can have a vessel multiple engines ending up with a large ISP, but it has a TWR of barely >1.1, while another vessel has an ISP of less then 1/4, but has a TWR of more than 2.

Maybe I'm calculating it wrong, is the ISP the sum or average of the individual ISPs of all the engines?

Edited by linuxgurugamer
Link to comment
Share on other sites

Ok, I can't get this to make any sense:

ts = (g - adry + sqrt( (g - adry)2 - 2*V*adry2/(Isp*g0) ) ) * (Isp*g0)/adry2

On a test, these numbers were pulled directly from a vessel:

I assumed that  g0 was equal to g for this:

  • g:  9.8
  • adry:  4.58
  • V: -26
  • Isp:  262

(9.8 - 4.58 + Sqrt((9.8 - 4.58)2 - 2*-26*4.582/(262*9.8))) * (262*9.8)/4.582

Excel formula:  =(9.8-4.58+SQRT(POWER(9.8-4.58,2)-2*(-26)*POWER(4.58,2)/(262*9.8)))*(262*9.8)/POWER(4.58,2)

I come up with a number of 1282, which is nonsense since my existing code (and flying it) showed that there was about 6 seconds of burn time, with a distance of about 91m during the travel

 

Link to comment
Share on other sites

Also, why such a complicated formula?

To calculate burn time to stop the vessel, it's essentially:  t = speed / (total thrust - g)

Ignoring atmosphere, of course.

and, the distance traveled over this is:   1/2 * (total thrust - g) * t2

It's a simple formula, why is yours so complicated?

I'm trying to understand this, you seem to have some knowledge I don't, so maybe I'm missing something here.

Edited by linuxgurugamer
Link to comment
Share on other sites

Just now, linuxgurugamer said:

Also, why such a complicated formula?

To calculate burn time to stop the vessel, it's essentially:  t = speed / (total thrust - g)

Ignoring atmosphere, of course.

and, the distance traveled over this is:   1/2 * (total thrust - g) * t2

It's a simple formula, why is yours so complicated?

I am no expert but I believe his code takes into account the change in thrust as the mass of the ship goes down with the burn. 

Link to comment
Share on other sites

2 minutes ago, captinjoehenry said:

I am no expert but I believe his code takes into account the change in thrust as the mass of the ship goes down with the burn. 

Maybe, but something is wrong, the numbers I"m getting from his calculation are not even close to what I'm seeing.  And, in my testing, the mass isn't changing that much, I'm doing 10 second burns 

Edited by linuxgurugamer
Link to comment
Share on other sites

Just now, linuxgurugamer said:

Maybe, but something is wrong, the numbers I"m getting from his calculation are not even close to what I'm seeing.

Hmm.  Well considering the code is referring to ISP and Acceleration it might be calculating the required fuel burn?  Honestly I'm not sure now that I look at it more but you should only be looking at ISP for figuring out either delta V which doesn't seem to be the case or the amount of fuel that needs to be burned.  So maybe it is a fuel requirement?  Not sure as including ISP seems a bit random for calculating a time for suicide burn.

Link to comment
Share on other sites

Whenever I find a formula spitting out nonsense I make sure my units all match up and cancel out properly, partly to make sure I'm putting in the right number! They don't from what I can tell. The way it's set up you should end with a unit of seconds, but you end in m/s2. due to those addition terms. If I'm following the order of operations correctly it cancels down to m/s2 - m/s2 + s , and you can't do that. So I messed up the order of operations in this analysis or the formula is flawed. If I do only the term in seconds I get something like 644 s which is also not right.

Link to comment
Share on other sites

On 5/15/2017 at 3:22 PM, linuxgurugamer said:

PID???

A controller based on a feedback input signal. PID stands for Proportional, Integral, Derivative -- the three ways the controller can process input data.

For instance, you could control velocity of a car by comparing your actual velocity (using it as an input feed) against a target velocity and adjust throttle proportionally to how far you're over or under the target velocity.

Or, you could control your velocity by measuring the distance to a control point and adjust throttle proportionally to how that distance changes over time (derivative)

Similar you could integrate your measurements over time and use that as your input signal. Integrating and deriving "on the fly" may sound horribly complicated but it's actually something that is fairly easy to do (with reasonable accuracy) with analog circuits; PID controllers have been built for over a century and are fairly well understood as a means to control dynamic processes.

The SAS units are PID controlled for instance.

Link to comment
Share on other sites

@linuxgurugamer, ahhh, so many new questions...

So, about everything:

g is the free fall acceleration at the point where ship is (or rather halfway from there to the surface). On Kerbin, it is roughly g0, but the formula wasn't written with only Kerbin in mind.

adry is the acceleration in m/s2, from engines only. 4.58 is clearly too low for Kerbin landing, so I'm assuming it is the acceleration after subtracting g, and the value the formula really required is 14.38.

I was very "kind" to omit that vertical speed is signed and negative for going down, many apologies. Glad you figured it out from my vague description.

ISP is the average of all thrusters, and (ISP*g0) is the effective exhaust speed in m/s, which in turn is (total thrust in kN/propellant consumption in tons/sec). This is identical to the formula from wiki:

f877f2fb908aece5893f346e0c1fd7e9.png

The complex formula accounts for mass change during the burn, as @captinjoehenry pointed out.

 t' = speed / (total thrust / mass - g) is systematically overestimating the time needed because it uses just the high mass at the start of the burn, so in the case of high speeds and low initial TWRs you stop too high above the ground when using it (tested for Mun lander going down at ~100 m/s with TWR ~1.3). BUT, this rough estimate is useful for the estimate of adry: adry ~ Thrust / (m0 - t'*consumption_rate).

With the corrected adry, the formula gives 5.42 s burn time and 71.5 m vertical travel, fairly close to your values (91m is clearly too much, because even at constant acceleration, distance is (V2 -  V02)/(2a) = (02 - 262) / (2*4.58) = 73.8m, and acceleration increases due to fuel burnout).

Edited by Pand5461
Link to comment
Share on other sites

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