HoneyFox

[0.25] Orbit Manipulator Series (Updated March 12 2014)

Recommended Posts

While waiting for eggRobin's awesome NBody plugin to finish, I tried to write this for earlier trial. And I need to thank Fractal_UK for sharing technique of manipulating orbits.

This series provide three features:

1. A very simple(primitive) linear limited NBody implementation. Not quite accurate but still give some challenges for mun transfer orbit or even interplanetary transfer. It will only affect the vessel you are controlling, and only by celestial bodies. default ON, toggle: RCtrl+RAlt+N.

It has an orbit predictor but it's very low efficient and buggy... lag the game quite a lot. default OFF, toggle: RAlt+N, restart prediction: LAlt+N.

2. AtmosphereDecay. All vessels that have Pe in atmosphere will have Ap go lower each time they get into atmosphere, even if they're on-rail. default ON, toggle: RAlt+D.

3. Warpable engine for those ion thrusters. You can use "Throttle" slider to setup the thrust in time-warp, you might then notice that these thrusters do have over-powered thrust...

A config to automatically add WarpableEngine module to those engines that use "XenonGas", "ArgonGas" or "HydrogenGas" is enclosed in the package as well.

screenshot77.png

The vessel has 8+1 ion thrusters and you can access their throttle-during-time-warp via the engine list GUI. (it also shows when in map view)

Dropbox link: https://www.dropbox.com/s/w8sgzy4q7gdlops/NBody.zip (Just updated (updated squared), re-DL please...)

Source-code on GitHub: https://github.com/HoneyFox/NBody/

Plugin is under MIT license.

Toolbar is made by blizzy78.

Toolbar icons drawn by myself, pretty simple and ugly. :P

This plugin package contains a .cfg file that requires Module Manager.

Change-log:

Fixed AtmosphereDecay not actually disabled/enabled by the button/hot-key. (yeah, quite silly mistake...)
Fix the issue that some vessel will hang there in atmosphere not falling (when they get close to Ap).
---------
Fix derived acceleration from vessel's main body and apply actual gravity of parent body of the vessel's main body to the vessel.
Add warpable-engine-list for convenient control in map view.
Add a settings.cfg to store options.
---------
Add toolbar integration so you have two buttons for NBody & AtmosphereDecay.
Refactor the orbit manipulator module and improve NBody a little.

Edited by HoneyFox
Tested in 0.25

Share this post


Link to post
Share on other sites

Minor update:

Fix issue that happens when multiple engines are running on time-warp.

Automatically adjust tweakables of all counterparts in flight, should ease user a lot when he/she is using an array of multiple ion thrusters.

P.S: This plugin needs more love. ;.;

Share this post


Link to post
Share on other sites

I promise to test it out just as soon as I have time :P.

Share this post


Link to post
Share on other sites

I'll give it a try next time I play. I'm particularly interested in the atmosphere decay feature of the plugin, because it bothers me a little that any stages I shed with a Pe < 20km or so seem to remain in orbit indefinitely.

Share this post


Link to post
Share on other sites
I'll give it a try next time I play. I'm particularly interested in the atmosphere decay feature of the plugin, because it bothers me a little that any stages I shed with a Pe < 20km or so seem to remain in orbit indefinitely.

It is quite annoying. and since realistic atmosphere decay will bring more troubles for LEO orbiters, I choose to only simulate the drag when they are really in KSP's atmosphere. (i.e. ~70km for stock Kerbin, ~104km for RSS Earth)

Share this post


Link to post
Share on other sites

I'm gonna try this out ASAP. This looks epic. BTW, how large is the atmosphere considered to be? Is the atmosphere 70km high, or do we get an exosphere as well?

EDIT: Nevermind, you ninja'd me with the answer :)

Edited by FanaticalFighter

Share this post


Link to post
Share on other sites
I'm gonna try this out ASAP. This looks epic. BTW, how large is the atmosphere considered to be? Is the atmosphere 70km high, or do we get an exosphere as well?

EDIT: Nevermind, you ninja'd me with the answer :)

Technically speaking, it's no difference whether to simulate exosphere or not, but it's too hard & tiring for players to manually maintain orbits for different orbiters, especially when you have an interplanetary mission underway that might take several months or years.

Share this post


Link to post
Share on other sites

This looks extraordinarily interesting, I will definitely check it out! I particularly like the idea of timewarping during ion thruster burns and the atmospheric decay. n-body physics will be definitely a challenge to learn though. Kudos to you!

EDIT:

I've tried it out (mainly the n-body physics, I have to admit) and it is a lot of fun so far. My only complaint is that the n-body physics is very confusing (as I don't know the L-points offhand, I had to have a Wikipedia page open in another window) and given as I have not much experience with n-body physics, I'm not really sure of what other benefits it offers.

Perhaps a readme file that explains what new things you can do, as well as how the orbit predictor works (it might be that I haven't really gone into any orbits that are affected too much, as I didn't notice much of a difference).

The only bug I've really noticed is that a white square appears around the cursor when zooming in or out in map view.

Other than that, excellent work!

Edited by CalculusWarrior

Share this post


Link to post
Share on other sites
This looks extraordinarily interesting, I will definitely check it out! I particularly like the idea of timewarping during ion thruster burns and the atmospheric decay. n-body physics will be definitely a challenge to learn though. Kudos to you!

EDIT:

I've tried it out (mainly the n-body physics, I have to admit) and it is a lot of fun so far. My only complaint is that the n-body physics is very confusing (as I don't know the L-points offhand, I had to have a Wikipedia page open in another window) and given as I have not much experience with n-body physics, I'm not really sure of what other benefits it offers.

Perhaps a readme file that explains what new things you can do, as well as how the orbit predictor works (it might be that I haven't really gone into any orbits that are affected too much, as I didn't notice much of a difference).

The only bug I've really noticed is that a white square appears around the cursor when zooming in or out in map view.

Other than that, excellent work!

Frankly speaking, i'm planning to disable/remove the N-body part of this plugin because it's implemented quite inaccurately, the orbit predictor works even worse that it will kill FPS quite a lot.

For the rest two features:

you can try launching a payload (with ion thruster + xenon gas on-board) onto LEO, make sure your upper stage cut-off and release the payload when orbit's Pe is still in atmosphere (if in stock KSP, I recommand ~50km, in RSS I recommend ~80km) and you need to use payload's ion thruster (set its Throttle to 100 and use time-warp for testing, make sure you have sufficient power supply) to do the last part of job to get into orbit. Then watch how the upper stage finally reentry while you are still controlling the payload.

Share this post


Link to post
Share on other sites

Alright, I've tested out the other two features (with n-body physics turned off). Unfortunately, the timewarping ion engines feature appears to be very finnicky, I was only able to activate it once. The debris reentry feature works well; it is hard to tell if it is active, though. Perhaps you could move away from keyboard shortcuts and instead use a window (like what the Distant Object Enhancement mod has done).

Is there a specific method to the ion engine timewarp? I try to throttle up while time warping, but nothing changes.

Share this post


Link to post
Share on other sites
Alright, I've tested out the other two features (with n-body physics turned off). Unfortunately, the timewarping ion engines feature appears to be very finnicky, I was only able to activate it once. The debris reentry feature works well; it is hard to tell if it is active, though. Perhaps you could move away from keyboard shortcuts and instead use a window (like what the Distant Object Enhancement mod has done).

Is there a specific method to the ion engine timewarp? I try to throttle up while time warping, but nothing changes.

That's strange. There is a design in the plugin which will automatically set the "Throttle" bar back to 0 every time you exit the time-warp (so that you won't mis-maneuver when you get into time-warp again).

It seems like you are changing the "Throttle" during time-warp aren't you? if that's right, make sure you still have sufficient electric charge & xenon gas. For some unknown reason, KSP doesn't handle resource consuming/generating correctly during time-warp, you will easily be out of EC with ion thrusters on during time-warp.

And to judge whether the ion engine really works or not, just right-click the engine and see its context menu. The thrust value displayed there is kept updated (and propellant-deprived/flame-out information as well)

As for moving away from keyboard shortcuts, I'm considering adding some information display. It is not easy to check if certain function is on or off currently.

Edited by HoneyFox

Share this post


Link to post
Share on other sites

I see. Yes, the throttle bar on the engine works fine. I was simply trying to warp too fast, it doesn't seem to work above 100x timewarp (I'm assuming you disabled that).

One last bug though. When observing debris' decaying orbits, I noticed that its orbit would shrink down until about 40 km, when the piece of debris would act oddly. Rather than continue to fall towards the planet, it seemed like all of its vertical velocity was gone, which made it 'orbit' the planet, even though its periapsis was deep inside the planet itself. Its horizontal speed kept decreasing though, and eventually it reached about 500 m/s. I believe the laws of physics began to work upon it again, and it disappeared.

I have to say, this is a truly great mod.

Share this post


Link to post
Share on other sites
I see. Yes, the throttle bar on the engine works fine. I was simply trying to warp too fast, it doesn't seem to work above 100x timewarp (I'm assuming you disabled that).

One last bug though. When observing debris' decaying orbits, I noticed that its orbit would shrink down until about 40 km, when the piece of debris would act oddly. Rather than continue to fall towards the planet, it seemed like all of its vertical velocity was gone, which made it 'orbit' the planet, even though its periapsis was deep inside the planet itself. Its horizontal speed kept decreasing though, and eventually it reached about 500 m/s. I believe the laws of physics began to work upon it again, and it disappeared.

I have to say, this is a truly great mod.

I haven't put any kind of limit for time-warp rate... if you have sufficient resources (both xenon gas and electric charge) it should work in 1000x or 10000x or even higher rate.

As for that decay issue, I'm simply using the inverted direction of the vessel's velocity for drag direction, so it will lose its horizontal velocity all the time but the absolute value of vertical speed might decrease as the air gets denser when falling into lower atmosphere. I will do some more tests to observe that, can you provide some basic information about your debris? i mean, the mass and the speed when entering the atmosphere?

Edited by HoneyFox

Share this post


Link to post
Share on other sites

This looks very impressive, a proper fix for ion engines has been a long time coming now. But please add a license to your post.

Share this post


Link to post
Share on other sites
This looks very impressive, a proper fix for ion engines has been a long time coming now. But please add a license to your post.

I remember that i've added MIT license into the source code base on GitHub... let me check again...

Wondering if I need to restate this in my OP?

Share this post


Link to post
Share on other sites

The rules say that the license has to be in the forumpost as well, mostly because it makes it easier for me to see of I need to be bothersome or not :P

Share this post


Link to post
Share on other sites
The rules say that the license has to be in the forumpost as well, mostly because it makes it easier for me to see of I need to be bothersome or not :P

OK. let me update the OP together with a new release.

Share this post


Link to post
Share on other sites

I am loving playing around with this. I see what you mean about the n-body portion -though it is a lot of fun playing with Munar orbits. I think my record for an equatorial Mun orbit thus far is < 5 days with a com satellite. Playing with highly eccentric > 39.6 degree orbits now.

9 Days of a 300km 100km polar ~90 degree polar orbit of the Mun ended in surface impact. Watching the orbit change as the Mun revolved Kerbin I did notice some peculiarities. At the two locations where the Mun crosses Kerbins velocity vector around Kerbal my Munar satellite's perihelion (normally at the Northern Pole) would instantly jump +-90 towards the Equator. Over the course of several orbits this jump cut the normal extension of the periapsis by 1/4 leading to an elongating Aphelion and eventual "landing". Perihelion normal range for this orbit would bounce between 60-100km with the Aphelion gaining and losing the difference (conservation of momentum).

I guess what I am trying to say is, your n-body seems accurate enough to be fun and a teaser of what is possible. Great work. Seems to me like a few edge case exceptions could make this at least usable.

Edited by sirklick

Share this post


Link to post
Share on other sites
I am loving playing around with this. I see what you mean about the n-body portion -though it is a lot of fun playing with Munar orbits. I think my record for an equatorial Mun orbit thus far is < 5 days with a com satellite. Playing with highly eccentric > 39.6 degree orbits now.

9 Days of a 300km 100km polar ~90 degree polar orbit of the Mun ended in surface impact. Watching the orbit change as the Mun revolved Kerbin I did notice some peculiarities. At the two locations where the Mun crosses Kerbins velocity vector around Kerbal my Munar satellite's perihelion (normally at the Northern Pole) would instantly jump +-90 towards the Equator. Over the course of several orbits this jump cut the normal extension of the periapsis by 1/4 leading to an elongating Aphelion and eventual "landing". Perihelion normal range for this orbit would bounce between 60-100km with the Aphelion gaining and losing the difference (conservation of momentum).

I guess what I am trying to say is, your n-body seems accurate enough to be fun and a teaser of what is possible. Great work. Seems to me like a few edge case exceptions could make this at least usable.

That sounds weird...

Considering you have 300km*100km orbit, a slight orbit velocity change won't cause the Pe to move +/-90 degrees... I hope that it's not anything wrong inside KSP's orbit calculation... what level of time-warp are you using?

Share this post


Link to post
Share on other sites

Here to say (a) how awesome this is and (B) I can't wait to actually try it out (desktop, someday you will be mine again!)

Share this post


Link to post
Share on other sites
That sounds weird...

Considering you have 300km*100km orbit, a slight orbit velocity change won't cause the Pe to move +/-90 degrees... I hope that it's not anything wrong inside KSP's orbit calculation... what level of time-warp are you using?

1000x. At this level of time acceleration I can watch the oscillation of the orbit quite easily and it definitely jumps when the Muns position is at 9 and 3 if the sun is at 12 (on a clock face). I may try this again tomorrow with at lower warp to see if the behavior repeats.

Share this post


Link to post
Share on other sites

Not sure I want the complication of the actual n-body portion, but warp'd thrust, and orbital decay both appeal to me. One question - does the warp'd thrust work with Interstellar engines?

Share this post


Link to post
Share on other sites
Not sure I want the complication of the actual n-body portion, but warp'd thrust, and orbital decay both appeal to me. One question - does the warp'd thrust work with Interstellar engines?

You can always disable n-body portion by clicking that icon on the Toolbar. I will add a config to record these options later so that you don't need to close it every time you start a flight.

For the Interstellar engines, if the engine is using ModuleEngines/ModuleEnginesFX, it should be compatible. but you need to add a "WarpableEngine" module into it manually. For code example, check the "config.cfg" file in the NBody folder, which is adding that module to all engines that use "XenonGas", "HydrogenGas" or "ArgonGas" (well these are for Near Future pack, so the resource names might differ) as propellant.

Edited by HoneyFox

Share this post


Link to post
Share on other sites
You can always disable n-body portion by clicking that icon on the Toolbar. I will add a config to record these options later so that you don't need to close it every time you start a flight.

For the Interstellar engines, if the engine is using ModuleEngines/ModuleEnginesFX, it should be compatible. but you need to add a "WarpableEngine" module into it manually. For code example, check the "config.cfg" file in the NBody folder, which is adding that module to all engines that use "XenonGas", "HydrogenGas" or "ArgonGas" (well these are for Near Future pack, so the resource names might differ) as propellant.

Super. I'll play around with ModuleManager later and see if I can get it right, will share if I can.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now