Jump to content

Space Computer. Brought to you by kOS and hopefully many nerds.


Payload

Recommended Posts

For what I'm doing I don't think TWR has to be all that accurate. I'm not even checking it until I am coasting to apoapsis. So it wont change until burn time.

I think I see what your saying. We can use the circular orbital speed calc at the altitude we are currently at because that is equal to current orbital velocity - verticalspeed.

So just hammering out something that will give the an idea of the math we get.

set Radius to 600000 + apoapsis.

set iRadius to 600000 + altitude.

set tVel to ((mass*9.816)/Radius)^0.5.

set iVel to ((mass*9.816)/iRadius)^0.5.

set reqdV to (tVel-iVel).

All of that was wrong apparently.

That should get me required dV. Yes? Still need to be able to derive relative burn time from that, and it doesn't need to be all that accurate. The burn shouldn't be that long or you wont end up very circular no matter what you do. Also I thought you would like to know that I got your test craft into orbit with my launch script no problem. The issue being the orbit wasn't very circular. That is why I'm trying to fix that section to set the burn at a calculated time before eta:apoapsis.

I will eventually work on the gravity turn section too. Right now it is just set to be nominal for 2.0 average TWR or there about.

Edited by Payload
Link to comment
Share on other sites

No that's wrong. You should use big G, not little g. Big G is the gravitational constant of the universe. You've used the gravitational acceleration around Kerbin there.

Also I'm not sure about the circular orbit thing you said. You'd need to ask a better astronomer.

Edit.

Second thing i just realised. You cannot just use the radius for your final velocity calculation because the orbit at that point is NOT circular. You need the full calculation.

Edit.

Just use the full calculation for everything because frankly orbits are practically never circular.

Edited by Cpt. Kipard
Link to comment
Share on other sites

No that's wrong. You should use big G, not little g. Big G is the gravitational constant of the universe. You've used the gravitational acceleration around Kerbin there.

Also I'm not sure about the circular orbit thing you said. You'd need to ask a better astronomer.

Edit.

Second thing i just realised. You cannot just use the radius for your final velocity calculation because the orbit at that point is NOT circular. You need the full calculation.

Edit.

Just use the full calculation for everything because frankly orbits are practically never circular.

I need to know the dV to circularize. So I do need to know what my orbital speed should be for it to be circular at that altitude. Why wouldn't the bodies gravitational constant be correct since it is the major gravitational influence and it already takes into account the mass of the orbited body?

Whatever I guess I'm just confused. and I looked up Newtons gravitational constant. Yea that is harder to do even still. Further more it's not one single number. EVER. I mean Never. So good luck with that. I need to redo the whole G*M thing.

EDIT:

Ok so the KSP wiki lists both of these numbers. G=3.5316000×10^12 and M=5.2915793×10^22. I've never had to do any of this before. I am a computer programmer. I know how to do math. I have no idea what orbital calculations even look like. You can't give me some giant equation and expect me to look at it and know the answer is a simple constant number. This is what I am asking for. If the equations helped at all I wouldn't be asking.

Edit:

It appears I will need to know the eccentricity to calculate iVel. I can calculate eccentricity no problem. I've been doing it all week.

So.

set G to 3.5216000*(10^12).

set M to 5.2915793*(10^22).

set tVel to ((G*M)/Radius)^0.5.

That gets me a target velocity at least.

So I'm back down to having less information than I need.

I need to know how to calculate iVal now based on orbital eccentricity.

Wikipedia says this.

For an object in an eccentric orbit orbiting a much larger body, the length of the orbit decreases with eccentricity e, and is an ellipse. This can be used to obtain a more accurate estimate of the average orbital speed:

ca1292bae1fc983f05d621f99278e2c2.png

Edited by Payload
Link to comment
Share on other sites

G = gravitational constant of the universe = 6.67384*(10^-11)

M = Mass of orbited body = 5.2915793*(10^22) for Kerbin

μ = standard gravitational parameter = G*M = 3.5216000*(10^12) for Kerbin

Gravitational constant and gravitational parameter are not the same thing.

All of your velocities and deltav wherever you are can be calculated using Vis-Viva.

You use the product of the gravitational constant and mass OR the standard gravitational parameter:

v = G*M*(1/r-2/a)^0.5

is the same as

v = μ*(1/r-2/a)^0.5

r = your **current** distance from the center of the orbited body = altitude + equatorial radius of the orbited body = altitude + 600000 (for Kerbin)

a = semi-major axis of your orbit = (apoapsis+peripsis+(2*equatorialRadius))/2

Since we always burn at periapsis or apoapsis then r will always be:

equatorialRadius + apoapsis (if you're at apoapsis)

or

equatorialRadius + periapsis (if you're at periapsis)

Always use the full calculation. When changing your orbit all you need to do is find out your current semi-major axis then solve for your current v.

Then find out the semi-major axis of your desired orbit and again solve for v.

your r will be the same for both calculations, since you barely change your position during the burn, and if you perform half of your burn before the apoapsis/periapsis and half of it after then it all works out perfectly.

Then you just subtract.

targetv - currentv = deltav

If the number is positive, then you burn prograde. If it's negative you burn retrograde.

Sorry to dumb this down so much but it's better than constantly elaborating.

Edit:

That wikipedia quote has nothing to do with what you're trying to do here.

Edit.

How did you manage to circularise your orbit without vis-viva????

Edit.

Things get a little more interesting when you're at apoapsis and trying to increase your periapsis to be your apoapsis, but I hope you can figure this out. You just treat your current apoapsis as the periapsis of your new orbit.

Edited by Cpt. Kipard
Link to comment
Share on other sites

G = gravitational constant of the universe = 6.67384*(10^-11)

M = Mass of orbited body = 5.2915793*(10^22) for Kerbin

μ = standard gravitational parameter = G*M = 3.5216000*(10^12) for Kerbin

Gravitational constant and gravitational parameter are not the same thing.

All of your velocities and deltav wherever you are can be calculated using Vis-Viva.

You use the product of the gravitational constant and mass OR the standard gravitational parameter:

v = G*M*(1/r-2/a)^0.5

is the same as

v = μ*(1/r-2/a)^0.5

r = your **current** distance from the center of the orbited body = altitude + equatorial radius of the orbited body = altitude + 600000 (for Kerbin)

a = semi-major axis of your orbit = (apoapsis+peripsis+(2*equatorialRadius))/2

Since we always burn at periapsis or apoapsis then r will always be:

equatorialRadius + apoapsis (if you're at apoapsis)

or

equatorialRadius + periapsis (if you're at periapsis)

Always use the full calculation. When changing your orbit all you need to do is find out your current semi-major axis then solve for your current v.

Then find out the semi-major axis of your desired orbit and again solve for v.

your r will be the same for both calculations, since you barely change your position during the burn, and if you perform half of your burn before the apoapsis/periapsis and half of it after then it all works out perfectly.

Then you just subtract.

targetv - currentv = deltav

If the number is positive, then you burn prograde. If it's negative you burn retrograde.

Sorry to dumb this down so much but it's better than constantly elaborating.

Edit:

That wikipedia quote has nothing to do with what you're trying to do here.

Edit.

How did you manage to circularise your orbit without vis-viva????

Edit.

Things get a little more interesting when you're at apoapsis and trying to increase your periapsis to be your apoapsis, but I hope you can figure this out. You just treat your current apoapsis as the periapsis of your new orbit.

No my r will not be the same for both calculations. One is 69500m and one is tOrbit. Or apoapsis if you will. I need to know my average orbital velocity when I shut the engines off at 69500. They wont be fired again until tTime which is expressed as thus.

when eta:apoapsis < tTime then { do this. }.

I don't think you understand what I am trying to do here. I need to calculate how much dV it will take to circularize before I get to apoapsis because I need to know how long the burn at apoapsis will take. I can't wait until I'm there or it's too late. I need to know that information at 69500m not at apoapsis. Of course the eccentricity of my current orbit matters. No I cannot reuse r. Unless you think 69500 and infinity are the same thing.

EDIT:

I don't know... I thank you for trying to help but you really aren't. I don't understand why you are subtracting 2 from r in that equation. I think I have a handle on this just by getting an average Vo at 69500m by using an average orbital altitude. iRadius = Apoapsis+Periapsis/2+600000. So then I could just pretend it was a circular orbit to begin with. So then in real terms. I can say that if my average orbital velocity at INITIAL or 69500m is iVel. Then I should be able to subtract iVel from tVel to get reqdV. Acceleration = maxthrust/mass. Then time = reqdV/acceleration and tTime = time/2.

Is this totally off base or what? Seems right to me. At this point all I see is a sea of Greek alphabet.

Edited by Payload
Link to comment
Share on other sites

No my r will not be the same for both calculations.

Um. when I said "current" i meant "during the burn". And that doesn't change for circularisation does it. Why would you assume that I'm telling you to calculate burns NOT at the place where you actually burn, come on...

I don't think you understand what I am trying to do here.

I do. Just read what I gave you carefully and apply it. I've used it before for very precise orbit changes and it works.

I don't understand why you are subtracting 2 from r in that equation

LOL WTF? Are you telling me you don't understand orders of operations?

Edited by Cpt. Kipard
Link to comment
Share on other sites

LOL WTF? Are you telling me you don't understand orders of operations?

Are you telling me you think you understand the op order when the man who made kOS himself said the thing executes divides and multiplies out of order sometimes. So yea. I don't understand that. So thanks for proving your excellent mathematical prowess but it still isn't helping me or any other non mathematician. If you expect me to understand through text you must make it as simple as possible.

I don't think you understand. See because you don't even understand how my code works. None of this math matters when I am actually burning. It matters before. Long before. The burn length isn't used when I am burning. The code doesn't even care. It sets throttle to 1 at tTime and sets throttle to .1 when periapsis is 10% of apoapsis and it sets throttle to 0 when periapsis is 1% of apoapsis OR when apoapsis is greater than the projected orbit altitude by 1km.

For now, I have been setting tTime by pure observation. All I care about is how long that burn will take. The code handles the burn it-self with logic and not obtuse use of arithmetic. I succeeded a long time ago for writing a script that will orbit one craft. I want to orbit all the crafts all the time provided you have the thrust and dV.

I do thank you for helping me with the constants. I would have never known that unless you told me. Please bear with me. You do have to understand that terms like "the full thing" that makes no sense to me. I don't even know what half the thing is. In essence I was asking what the full thing is.

I suggested that one could get the average Radius of the orbit and preform that calculation as if the orbit where circular.

Because average velocity is all that matters.

We know the average velocity for a circular orbit because it is the same as the actual orbital velocity.

So therefore I must be able to conclude that u/averageradius^0.5 = average orbital velocity or my Initial as it where. iVel

And I want the target velocity of the apoapsis which we can also say is the average orbital velocity at that height. tVel

If all of the previous things are true. Then reqdV is what? I know the target velocity will be less based on the law of orbits.

Real case examples.

I exit the atmosphere at 69500 and my apoapsis is 100km. My Periapsis is 0km. This is actually what I have observed from nearly nominal accent perameters. The average radius is 50Km+600000. Since we won't be hitting the atmosphere, much less the ground, anytime soon. The fact that the orbit is elliptical doesn't really matter. The period and average velocity are the exact same for a no atmosphere 50km orbit and an elliptical 100km by 0km orbit. I am having trouble understanding how to derive dV from those two values.

So please forgive me that I am asking you to be verbose. I really don't understand half of the things you are talking about. I understand how to make the computer do math. I prefer to be as verbose as possible when I am testing arithmetic code so that I can debug it more easily. So yes I tend to do math in stages and reduce it when I know it is correct.

Link to comment
Share on other sites

Think of it as a Hohmann transfer orbit where you start off in the elliptical orbit.

So provided you are circularizing at Apoapsis you need to burn:

Uds5LOU.png

m/s of dV.

I don't really know why you would bother calculating that though. You have access to apoapsis and periapsis height and eta. So you can just make a control loop:

clearscreen.

print "Waiting for apo".

set I to 0.
set F to 0.
lock steering to prograde.
set X to 1.


wait until ETA:APOAPSIS < 30.
print "Initializing circularization protocol!".

until F=1 {
set error to (apoapsis - periapsis)/(apoapsis+periapsis+1200000).
if error>X { set F to 1. }.
lock throttle to 10*error.

set TAp to eta:apoapsis.
set TPe to eta:periapsis.

if (TPe<TAp) {
set X to 200*(TAp - 2*TPe)/(0.5*(TAp-TPe)).
}.


if (TAp<TPe) {
set X to 200*(0 - TAp)/(0.5*(TPe-TAp)).
}.

if X>90 {set X to 90.}.
if X<-90 {set X to -90.}.
lock steering to prograde + R(0,X+I,0).

set X to error.
}.

print "Done!".

This is what I wrote as a circularization script. It is still a bit buggy (And I need to fix it to work with lowering orbits) but it usually gets the difference between apo and peri down to 100 meters.

Link to comment
Share on other sites

I don't think you understand. See because you don't even understand how my code works. None of this math matters when I am actually burning. It matters before. Long before. The burn length isn't used when I am burning. The code doesn't even care. It sets throttle to 1 at tTime and sets throttle to .1 when periapsis is 10% of apoapsis and it sets throttle to 0 when periapsis is 1% of apoapsis OR when apoapsis is greater than the projected orbit altitude by 1km.

You're right I didn't know what your code was doing, and I see where the confusion comes from now. It would never occur to me to do it your way because that's not how real rocket scientists do it. They do it by calculating thrust and timing the burn correctly, which is what I was attempting to show you. This way doesn't care about checking for the desired orbit. it only measures the initial orbit and calculates necessary dv to get to the desired orbit. And that's where precise acceleration and timing come in. Maybe it's just a matter of preference. I like to do things realistically when I can.

... average velocity...

Just no. I have to assume you mean average speed, because the average orbital velocity is 0 for all elliptical orbits, but still.... no. Just forget that notion. It's irrelevant.

I really don't know what else to do. I've explained how to calculate the burn time and how to calculate dv and assuming a constant force (which is also easy to do by dynamically throttling down) that is ALL you need to change your orbit. Nothing else.

Maybe it'll be better if each one of us just tries their own way and we'll test each one.

I don't really know why you would bother calculating that though. You have access to apoapsis and periapsis height and eta. So you can just make a control loop:

....

This is what I wrote as a circularization script. It is still a bit buggy (And I need to fix it to work with lowering orbits) but it usually gets the difference between apo and peri down to 100 meters.

Well if you code works then we should use it although (correct me if I'm wrong) your script will use more processor time, because it loops. I don't know. My way just does the initial calculations and locks the throttle to a function of mass then waits a specific amount of time.

Link to comment
Share on other sites

Think of it as a Hohmann transfer orbit where you start off in the elliptical orbit.

So provided you are circularizing at Apoapsis you need to burn:

Uds5LOU.png

m/s of dV.

I don't really know why you would bother calculating that though. You have access to apoapsis and periapsis height and eta. So you can just make a control loop:

clearscreen.

print "Waiting for apo".

set I to 0.
set F to 0.
lock steering to prograde.
set X to 1.


wait until ETA:APOAPSIS < 30.
print "Initializing circularization protocol!".

until F=1 {
set error to (apoapsis - periapsis)/(apoapsis+periapsis+1200000).
if error>X { set F to 1. }.
lock throttle to 10*error.

set TAp to eta:apoapsis.
set TPe to eta:periapsis.

if (TPe<TAp) {
set X to 200*(TAp - 2*TPe)/(0.5*(TAp-TPe)).
}.


if (TAp<TPe) {
set X to 200*(0 - TAp)/(0.5*(TPe-TAp)).
}.

if X>90 {set X to 90.}.
if X<-90 {set X to -90.}.
lock steering to prograde + R(0,X+I,0).

set X to error.
}.

print "Done!".

This is what I wrote as a circularization script. It is still a bit buggy (And I need to fix it to work with lowering orbits) but it usually gets the difference between apo and peri down to 100 meters.

OMG I don't know why I would want the computer to do the calculation once when it could obviously be wasting cpu cycles doing over and over. Is that a trick question? You don't need a control loop to handle this. I see your loop doesn't even start until eta:apoapsis < 30. What if you have a burn time longer than one minute? What happens then? That could happen with a highly elliptical orbit and a low TWR insertion stage.

Ok I've cracked it anyway. I think....

3.5316000e12/650000^.5=2330ms. Exactly like here. http://files.arklyffe.com/orbcalc.html

and 3.5316000e12/700000^.5=2246ms. Also closely corroborated by that Orbital calc.

So that is terms iVel and tVel solved. tVel-iVel= -84ms. That also jives with what the orbital calc is telling me for circularizing at apoapsis with a 100k x 0km orbit. All but the sign anyway. So I need to do a sign change or have I done some math wrong?

What is even worse is I've been doing those calcs on paper for the last three hours and not getting the right answers. You know what my problem was? I wrote down 3.5316000x10.e12.... Face palm... Yep that is one more 0 than 3.5316000e12... Ugghhhh...

THOSE DANG ZEROS... Epic fail...

Just no. I have to assume you mean average speed, because the average orbital velocity is 0 for all elliptical orbits, but still.... no. Just forget that notion. It's irrelevant.

I really don't know what else to do. I've explained how to calculate the burn time and how to calculate dv and assuming a constant force (which is also easy to do by dynamically throttling down) that is ALL you need to change your orbit. Nothing else.

Maybe it'll be better if each one of us just tries their own way and we'll test each one.

Nope a 50k x 50k orbit is computationally the same as 100k x 0k in this case. As a matter of fact. Do the math yourself. I just did. If you just do the math like the orbit is circular, but you use your average orbital altitude like.... apoapsis+periapsis/2 + 600000. Does that not = 650000. It does and here is why.

The transverse orbital speed is inversely proportional to the distance to the central body because of the law of conservation of angular momentum, or equivalently, Kepler's second law. This states that as a body moves around its orbit during a fixed amount of time, the line from the barycenter to the body sweeps a constant area of the orbital plane, regardless of which part of its orbit the body traces during that period of time. This law is usually stated as "equal areas in equal time.

This law implies that the body moves faster near its periapsis than near its apoapsis, because at the smaller distance it needs to trace a greater arc to cover the same area.

Mind=Blown. And yes I meant speed.

Edited by Payload
Link to comment
Share on other sites

OMG I don't know why I would want the computer to do the calculation once when it could obviously be wasting cpu cycles doing over and over. Is that a trick question? You don't need a control loop to handle this. I see your loop doesn't even start until eta:apoapsis < 30. What if you have a burn time longer than one minute? What happens then? That could happen with a highly elliptical orbit and a low TWR insertion stage.

What else do you want to use those CPU cycles for? Are you trying to play doom on kOS while circularizing? If you're worried that it hogs down your actual CPU just add a "wait 0.05" in the loop. A control loop is less error prone and more versatile in my opinion.

Oh, and if you'd read the script you'd see that if the burntime was longer than 1 minute the ship would just pitch up or down to keep eta:apoapsis close to 0. So it would work just fine.

Link to comment
Share on other sites

What else do you want to use those CPU cycles for? Are you trying to play doom on kOS while circularizing? If you're worried that it hogs down your actual CPU just add a "wait 0.05" in the loop. A control loop is less error prone and more versatile in my opinion.

Oh, and if you'd read the script you'd see that if the burntime was longer than 1 minute the ship would just pitch up or down to keep eta:apoapsis close to 0. So it would work just fine.

I don't know about you, but my FPS tanks drastically when running anything but simple loops in kOS. Also my answer to what could I be doing with those CPU cycles. I don't know... Hmm stage watching maybe... Perhaps.. Low fuel warning. Basically anything I want.

Link to comment
Share on other sites

Also closely corroborated by that Orbital calc.

In other words wrong. You keep confusing concepts and variables. All you did was calculate the difference between orbital speeds of two different circular orbits. That's not the same as calculating the necessary dv for each burn. Even on that page it tells you how much dv you need to expend:

periapsis: 1250.0000 km, apoapsis: 1300.0000 km

periapsis: 650.0000 km AMSL, apoapsis: 700.0000 km AMSL

velocity at periapsis: 1697.0 m/s, at apoapsis: 1631.7 m/s

Hohmann delta-v at periapsis: 16.4 m/s, at apoapsis: 16.2 m/s

Vesc at periapsis: 2376.7 m/s, at apoapsis: 2330.5 m/s

period: 80.2 minutes

semimajor axis: 1275.0000 km

semiminor axis: 1274.7549 km

eccentricity: 0.0

specific orbital energy: -1384.4682 kJ/kg

Why is this so hard to grasp? You keep screwing up because you're trying to do short cuts and it's getting ridiculous. If you want to time your burn with a variable then just do what I explained to you.

Link to comment
Share on other sites

In other words wrong. You keep confusing concepts and variables. All you did was calculate the difference between orbital speeds of two different circular orbits. That's not the same as calculating the necessary dv for each burn. Even on that page it tells you how much dv you need to expend:

periapsis: 1250.0000 km, apoapsis: 1300.0000 km

periapsis: 650.0000 km AMSL, apoapsis: 700.0000 km AMSL

velocity at periapsis: 1697.0 m/s, at apoapsis: 1631.7 m/s

Hohmann delta-v at periapsis: 16.4 m/s, at apoapsis: 16.2 m/s

Vesc at periapsis: 2376.7 m/s, at apoapsis: 2330.5 m/s

period: 80.2 minutes

semimajor axis: 1275.0000 km

semiminor axis: 1274.7549 km

eccentricity: 0.0

specific orbital energy: -1384.4682 kJ/kg

Why is this so hard to grasp? You keep screwing up because you're trying to do short cuts and it's getting ridiculous. If you want to time your burn with a variable then just do what I explained to you.

Too bad it's not wrong. You aren't understanding what the calculator is telling you.

periapsis: 600.0000 km, apoapsis: 700.0000 km

periapsis: 0.0000 km AMSL, apoapsis: 100.0000 km AMSL

velocity at periapsis: 2517.3 m/s, at apoapsis: 2157.7 m/s

Hohmann delta-v at periapsis: 91.6 m/s, at apoapsis: 88.1 m/s

Vesc at periapsis: 3430.4 m/s, at apoapsis: 3176.0 m/s

period: 29.2 minutes

semimajor axis: 650.0000 km

semiminor axis: 648.0741 km

eccentricity: 0.1

specific orbital energy: -2715.6877 kJ/kg

-----------------------------------------------------------------------------------------

periapsis: 650.0000 km, apoapsis: 650.0000 km

periapsis: 50.0000 km AMSL, apoapsis: 50.0000 km AMSL

velocity at periapsis: 2330.5 m/s, at apoapsis: 2330.5 m/s

Hohmann delta-v at periapsis: 0.0 m/s, at apoapsis: 0.0 m/s

Vesc at periapsis: 3295.9 m/s, at apoapsis: 3295.9 m/s

period: 29.2 minutes

semimajor axis: 650.0000 km

semiminor axis: 650.0000 km

eccentricity: 0.0

specific orbital energy: -2715.6877 kJ/kg

Noticing anything similar?

You can do that with any orbit.

_______________________________________________

50k and 200k what's the SMA? It's 725k that's what. What is the SMA of 125k circular orbit? Is it 725k? What is the orbital period?

periapsis: 650.0000 km, apoapsis: 800.0000 km

periapsis: 50.0000 km AMSL, apoapsis: 200.0000 km AMSL

velocity at periapsis: 2448.1 m/s, at apoapsis: 1989.1 m/s

Hohmann delta-v at periapsis: 117.6 m/s, at apoapsis: 111.6 m/s

Vesc at periapsis: 3295.9 m/s, at apoapsis: 2970.9 m/s

period: 34.4 minutes

semimajor axis: 725.0000 km

semiminor axis: 721.1103 km

eccentricity: 0.1

specific orbital energy: -2434.7545 kJ/kg

-------------------------------------------------------------------------------------------

What about 125 circular.

periapsis: 725.0000 km, apoapsis: 725.0000 km

periapsis: 125.0000 km AMSL, apoapsis: 125.0000 km AMSL

velocity at periapsis: 2206.7 m/s, at apoapsis: 2206.7 m/s

Hohmann delta-v at periapsis: 0.0 m/s, at apoapsis: 0.0 m/s

Vesc at periapsis: 3120.7 m/s, at apoapsis: 3120.7 m/s

period: 34.4 minutes

semimajor axis: 725.0000 km

semiminor axis: 725.0000 km

eccentricity: 0.0

specific orbital energy: -2434.7545 kJ/kg

_________________________________________________________

But lets do yours.

You have set periapsis to 650k and apoapsis to 700k. Alright no problem

650000+700000/2 + 600000 = 1275000 SMA? Lets just see..

periapsis: 1250.0000 km, apoapsis: 1300.0000 km

periapsis: 650.0000 km AMSL, apoapsis: 700.0000 km AMSL

velocity at periapsis: 1697.0 m/s, at apoapsis: 1631.7 m/s

Hohmann delta-v at periapsis: 16.4 m/s, at apoapsis: 16.2 m/s

Vesc at periapsis: 2376.7 m/s, at apoapsis: 2330.5 m/s

period: 80.2 minutes

semimajor axis: 1275.0000 km

semiminor axis: 1274.7549 km

eccentricity: 0.0

specific orbital energy: -1384.4682 kJ/kg

Note the orbital period.

Now lets see what the SMA is for a 675 circular... Hmmm. Could it possibly be 1275k. I don't know since I am apparently dumb. Lets have the calculator find out for us.

periapsis: 1275.0000 km, apoapsis: 1275.0000 km

periapsis: 675.0000 km AMSL, apoapsis: 675.0000 km AMSL

velocity at periapsis: 1664.0 m/s, at apoapsis: 1664.0 m/s

Hohmann delta-v at periapsis: 0.0 m/s, at apoapsis: 0.0 m/s

Vesc at periapsis: 2353.3 m/s, at apoapsis: 2353.3 m/s

period: 80.2 minutes

semimajor axis: 1275.0000 km

semiminor axis: 1275.0000 km

eccentricity: 0.0

specific orbital energy: -1384.4682 kJ/kg

That must be wizardry I guess.

Thus I pontificate that periapsis+apoapsis/2 + 600000 is exactly the same calc as circular. Thus you can treat any orbit as circular as long as you replace orbital altitude with the average orbital altitude. The periods are the same. The average speed is the same. The SMA is the same.

Read this.

http://en.wikipedia.org/wiki/Orbital_speed

It's a mathematical fact. You only need to know your average orbital altitude to get the SMA. Being in a 0k by 100k orbit is exactly the same as being in a 50k x 50k orbit. Well if you don't factor in that smacking into the ground problem anyway. :)

This is stupid really because we are arguing about the same thing just thinking about it differently. We should stop now. I'm getting correct answers and if it wasn't for you I wouldn't be.

Edited by Payload
Link to comment
Share on other sites

If you look at a dictionary definition for "Red Herring", then you'll see the above post. But that's ok, I'll just wait for your script.

Why wait.


set fApoapsis to 700000.
set fPeriapsis to 650000.

set Gk to 3.5316000*10^12.
set Radius to 600000 + fApoapsis.
set iRadius to 600000 + ((fApoapsis+fPeriapsis)/2).
set tVel to (Gk/Radius)^0.5.
set iVel to (Gk/iRadius)^0.5.
set reqdV to (iVel-tVel).
set acceleration to (maxthrust/mass).
set burnTime to (reqdV/acceleration).
set tTime to (burnTime/2).
print "".
print Radius.
print iRadius.
print iVel.
print tVel.
print reqdV.
print burnTime.
print tTime.

set aRadius to 600000 + fApoapsis.
set pRadius to 600000 + fPeriapsis.
set aVel to (Gk/aRadius)^0.5.
set pVel to (Gk/pRadius)^0.5.
set reqdV2 to ((pVel-aVel)/2).
set acceleration2 to (maxthrust/mass).
set burnTime2 to (reqdV/acceleration).
set tTime2 to (burnTime/2).
print " ".
print aRadius.
print pRadius.
print aVel.
print pVel.
print reqdV2.
print burnTime2.
print tTime2.
print " ".
if burnTime = burnTime2 { print "The burntimes are the same or this wouldn't print.". }.

zoS1Dnr.jpg

Now add your orbital calc to the bottom and see how different your burnTime is than mine. I'm interested since kOS barely has 1 second resolution anyway. Use the same constant since that is what is on the KSP wiki.

Well I guess we will have to call that close enough to good.

Link to comment
Share on other sites

Why wait.


set fApoapsis to 700000.
set fPeriapsis to 650000.

set Gk to 3.5316000*10^12.
set Radius to 600000 + fApoapsis.
set iRadius to 600000 + ((fApoapsis+fPeriapsis)/2).
set tVel to (Gk/Radius)^0.5.
set iVel to (Gk/iRadius)^0.5.
set reqdV to (iVel-tVel).
set acceleration to (maxthrust/mass).
set burnTime to (reqdV/acceleration).
set tTime to (burnTime/2).
print "".
print Radius.
print iRadius.
print iVel.
print tVel.
print reqdV.
print burnTime.
print tTime.

set aRadius to 600000 + fApoapsis.
set pRadius to 600000 + fPeriapsis.
set aVel to (Gk/aRadius)^0.5.
set pVel to (Gk/pRadius)^0.5.
set reqdV2 to ((pVel-aVel)/2).
set acceleration2 to (maxthrust/mass).
set burnTime2 to (reqdV/acceleration).
set tTime2 to (burnTime/2).
print " ".
print aRadius.
print pRadius.
print aVel.
print pVel.
print reqdV2.
print burnTime2.
print tTime2.
print " ".
if burnTime = burnTime2 { print "The burntimes are the same or this wouldn't print.". }.

zoS1Dnr.jpg

Now add your orbital calc to the bottom and see how different your burnTime is than mine. I'm interested since kOS barely has 1 second resolution anyway. Use the same constant since that is what is on the KSP wiki.

Well I guess we will have to call that close enough to good.

Thanks for this Payload. I'm going to test out setting up actual burn times for my circularization burn scripts now, considering mine was more of the loop until correct method, and while working, was rather slow.

Link to comment
Share on other sites

Thanks for this Payload. I'm going to test out setting up actual burn times for my circularization burn scripts now, considering mine was more of the loop until correct method, and while working, was rather slow.

Don't thank me yet. I may not be right! I only think I'm right! Plus I'm pretty sure that even though this works just fine for burn time. It may not work very well if you are counting on the dV to be accurate for MECO. Like I said, I use pure logic for MECO.

Current testing says it reduces my eccentricity by a factor of 8.

I bet someone recognizes this baby.

0D7gSkv.jpg

Before I added the burn time calc, this was giving me a .008 eccentricity. Orbital parameters at time of calc. I was 69500m into a -100k x 100k orbit.

Still I prefer this.

gqpKV4q.jpgp4KbbHX.jpg

That is the Jebpollo. It's got everything for a single guy. You will just have to pretend there are three.

Here is the craft file for Jebpollo. http://pastebin.com/2zp4N9MU Just save it as Jebpollo.craft in notepad. Make sure you are set it to all files so you don't get Jebpollo.craft.txt.

Here is the script that runs her. Make sure you remove the comments. Comments don't parse yet as far as I know. I just haven't worked the asparagus variables into the menu system yet. I haven't quite decided how I will do it. So that is why the comments are there incase you want to use asparagus staging you will know how.


clearscreen.
set rpAlt to 100.
set rProgram to 90.
set r to 180.
set p to 0.
set y to 0.
set orbit to 0.
set tOrbit to 100000.
set hAtmo to 69500.
set tAngle to up + R(y,p,r).
set tThr to 1.
set turn1 to 9999.
set turn2 to 14999.
set turn3 to 19999.
set turn4 to 24999.
set turn5 to 49000.
set selection to 0.
set flagup to 0.
set flagdown to 0.
set confirm to 0.
// If your rocket has no aparagus stages set Count to 0.
set Count to 0. // For aparagus. Count = Number of asparagus stages.
set aspFuel to 0. // aspFuel = The amount of liquidfuel in one asparagus stage.

on abort { toggle ag2. wait until verticalspeed < 0. toggle ag3. }.

print "Select your orbit altitude.".
print "--------------------------------".
print " ".
print " ".
print "Use action group 9 to add 10Km to orbit alt.".
print " ".
print "Use action group 8 to remove 10Km from orbit alt.".
print " ".
print "Use action group 7 to confirm orbit alt.".

until selection = 1
{
on ag9 set flagup to 1.
on ag8 set flagdown to 1.
on ag7 set confirm to 1.

if flagup = 1
{
clearscreen.
print "Select your orbit altitude.".
print "--------------------------------".
print " ".
print "Default orbit alt is set to " + tOrbit + "m".
print " ".
print "Use action group 9 to add 10Km to orbit alt.".
print " ".
print "Use action group 8 to remove 10Km from orbit alt.".
print " ".
print "Use action group 7 to confirm orbit alt.".
print " ".
set tOrbit to tOrbit + 10000.
print "You have selected " + tOrbit.
toggle ag9.
set flagup to 0.
}.

if flagdown = 1
{
clearscreen.
print "Select your orbit altitude.".
print "--------------------------------".
print "".
print "Default orbit alt is set to " + tOrbit + "m".
print " ".
print "Use action group 9 to add 10Km to orbit alt.".
print " ".
print "Use action group 8 to remove 10Km from orbit alt.".
print " ".
print "Use action group 7 to confirm orbit alt.".
print " ".
set tOrbit to tOrbit - 10000.
if tOrbit < 80000 { set tOrbit to 80000. }.
print "You have selected " + tOrbit + "m".
toggle ag8.
set flagdown to 0.
}.

if confirm = 1
{
clearscreen.
print " ".
print "You have confirmed " + tOrbit + "m".
print " ".
print "Lift Off in 5s.".
toggle ag7.
set confirm to 0.
wait 2.
set selection to 1.
}.
}.

set xOrbit to tOrbit + 1000.
set cAlt to tOrbit - (tOrbit*.05).
set xAlt to tOrbit - 1000.
set hAlt to tOrbit - 5.
clearscreen.
print "Orbit altitude set to " + tOrbit + "m".
lock steering to tAngle.
lock throttle to tThr.

print "3". wait 1.
print "2". wait 1.
print "1". Wait 1.
Print "Lift Off!". stage.

set StartFuel to <liquidfuel>.


when altitude > rpAlt then
{
set r to rProgram.
print "Roll Program".
}.

when altitude > turn1 then set p to -35.
when altitude > turn2 then set p to -45.
when altitude > turn3 then set p to -60.
when altitude > turn4 then set p to -75.
when apoapsis > turn5 then set p to -90.

when apoapsis > tOrbit then
{
toggle ag5.
set tThr to 0.
set Gk to 3.5316000*10^12.
set Radius to 600000 + apoapsis.
set iRadius to 600000 + ((apoapsis+periapsis)/2).
set tVel to (Gk/Radius)^0.5.
set iVel to (Gk/iRadius)^0.5.
set reqdV to (iVel-tVel).
set acceleration to (maxthrust/mass).
set burnTime to (reqdV/acceleration).
set tTime to (burnTime/2).
until altitude > hAtmo
{
if apoapsis < hAlt { set tThr to .1. }.
if apoapsis > tOrbit { set tThr to 0. }.
}.
when eta:apoapsis < tTime then set tThr to 1.
}.

when periapsis > cAlt then set tThr to .1.
when periapsis > xAlt then
{
if periapsis > xAlt OR apoapsis > xOrbit
{
set tThr to 0.
sas on.
print "You Are Now In Orbit".
set orbit to 1.
}.
}.

until orbit = 1
{
set StageSolid to stage:solidfuel.
Set StageLiquid to stage:liquidfuel.
set Lfuel to <liquidfuel>.
set tAngle to up + R(y,p,r).

if Lfuel < StartFuel - aspFuel AND Count > 0
{ stage. set StartFuel to Lfuel. set Count to Count - 1. }.

if StageSolid > 0 AND StageSolid < 1
{ stage. }.

if StageLiquid = 0 AND StageSolid = 0
{ if Lfuel > 0 { wait .1. stage. }. }.
}.

set tThr to 0.
toggle ag1.
print " ".
print "Apoapsis is " + apoapsis + "m".
print " ".
print "Periapsis is " + periapsis + "m".
print " ".
print "Orbital Eccentricity is " +
(((apoapsis + 600000)-(periapsis + 600000))/((apoapsis + 600000)+(periapsis + 600000))).
print " ".

EDIT: I forgot to add! Try the abort sequence anytime after lift off. Click the abort button to the left of the altimeter and wait. It does everything else. I still have to do it about 20 more times before I get it out of my system. So simple yet so cool. :)

Edited by Payload
Link to comment
Share on other sites

Another thing the language could use that I just ran into:

There's no way to abort the program other than trying to if-check around the whole thing. I wanted to put a check at the front of my script to say this:


if maxthrust = 0 {
print "ABORTING PROGRAM: No active engines right now.".
print "Do not run until after you've started up the engines.".
...Crud what goes here? break? abort?...
}.
... rest of program continues on from here.

There needs to be an "exit" or something like that. Or perhaps allow "break" outside a loop to mean exit.

Use CNTRL-C in the kOS window to break out of the program if you need to. I'm not really sure what your issue is. If you program is written correctly it should end when it's end conditions are met. The end condition can be written in to your main loop or it can be set to be before that with a "when then". I don't think this is something wrong with kOS or it's missing anything. It has everything you need. You just have to learn to use it. For instance my launch to orbit script ends when you are either in orbit or it knows you aren't going to make it.

Link to comment
Share on other sites

Clearly you missed what he is looking for. He is looking for some way to have the program self abort if you haven't started the engines. There is no 'abort' command to kill an entire program.

What you are talking about already exist. He just hasn't set it up correctly.

If you get stuck in a loop because of a program error you can just hit CNTRL-C.

Edited by Leonov
Link to comment
Share on other sites

It's already there you just have to program it. No good API for what? I already have code that stages everything and doesn't stage your parachutes and all of that. It is freely available in the space computer thread. It also will show you how to use a main loop and set various close conditions. So once again, I reiterate that what you want already exist, you just have to know how to set it up. If your program is structured correctly then you can end it anytime you like. Excessive nesting? What does that even mean? You think there is something wrong with nested conditionals? Because there isn't. You are asking for what exactly. A command to end your program? You have 100% control over what it does. So why do you need a command to do something you should have already programmed in from the beginning?

You know how I can end my program at any time I want? set done to 1.

Just so I can make it clear how simple it is.

All you need is a loop or a conditional wait at the end of your script and it's over. So we do this.

Example 1.


when THIS > WHATEVER then { print "You can even check in a when-then statement. Like this.". }.
when THIS > WHATEVER then { set CONDITION to SOMETHING }.
when THIS > WHATEVER then { do these things. }.


Until CONDITION = SOMETHING
{
do this.
Print "You want multiple conditions?".
print "It's easy!".
if THING = THIS { set CONDITION to SOMETHING }.
if APPLES = 0 { set CONDITION to SOMETHING }.

}.

All of those "when-then" things will still function until CONDITION = SOMETHING. He can set CONDITION to SOMETHING any time he wants. If he doesn't need the until loop to actually do anything,

he can just use the command wait until CONDITION = SOMETHING. in it's place. There is no need for an explicit exit program at all.

Edited by Leonov
Link to comment
Share on other sites

Executes a command when a certain criteria are met. Unlike WAIT, WHEN does not halt execution. Example:

WHEN BCount < 99 THEN PRINT BCount + “ bottles of beer on the wallâ€Â.

Edited by Leonov
Link to comment
Share on other sites

I don't think GOTO is the devil at all. The problem is new players latch on to it like a fish hook. They just wont let go. So you end up with GOTO everywhere and you can't follow the flow. I don't have any fundamental problem with EXIT either. Specifically when it can solve a problem. But it isn't a hammer and everything isn't a nail. I was simply demonstrating that he can still do exactly what he is asking by structuring his program in a sensible way. You don't have to use any loops if you don't want to. There is a "wait until" and that works just fine. "When then" is a one time trigger you can use and allow the program to halt on end condition. When then will not loop unless you imbed it into a loop. It's perfectly fine to have a script that looks like this.


when-then
when-then
when-then
.
.
.
.

wait until...

I prefer a loop at the end myself. Even if it is empty. Then it is already there for you to use for things like staging and throttle control. Hopefully we will get an EXIT AND RUN anyway because we need it. Then everyone is happy.

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...