Jump to content

[1.12.x] KSP Resonant Orbit Calculator


linuxgurugamer

Recommended Posts

  On 8/30/2018 at 9:49 PM, linuxgurugamer said:

1. Yes, being worked on.  Since you mentioned it, do you think having it be configurable for both the editor and in flight would be useful?

2. This only deals with perfect orbits.  If grabbing current parameters, how would you suggest it be done?  Get the Ap?  the Pe?  An average?

I suppose I could do that, but again, this is designed with a perfect circular orbit in mind.  I thought about this, and didn't want to have to start calculating a circulization maneuver.  I can see that becoming just a bit hairy.

Expand  

1. Well, personally, I would prefer to view the black variant at all times even in the editor. That's personal preference though so I'd probably refer to some feedback from the community.

2. Well you could grab the SMA and Eccentricity of the vessel and that should give you the current Ap and Pe (ignoring any other parameters such as Inc. and Arg. of Pe). Hmmmm... I mean, its probably only meaningful if you decide you want to go the whole hog here but you'd almost just be replicating MechJeb's Resonant Orbit function but your tool would be pre-calculating the resonance required for the number of sats in the network. It'd be a fair bit of work.

Link to comment
Share on other sites

  On 8/30/2018 at 10:04 PM, Poodmund said:

Well you could grab the SMA and Eccentricity of the vessel and that should give you the current Ap and Pe (ignoring any other parameters such as Inc. and Arg. of Pe). Hmmmm... I mean, its probably only meaningful if you decide you want to go the whole hog here but you'd almost just be replicating MechJeb's Resonant Orbit function but your tool would be pre-calculating the resonance required for the number of sats in the network. It'd be a fair bit of work.

Expand  

If I grab the current orbit, I will only grab a single number ( Ap, Pe, or average) and assume it to be circular.  

Link to comment
Share on other sites

Thinking about it, I think I can get some code from GravityTurn which will do most of what I would need to both do the maneuver and to set the maneuver node AND to tell mechjeb to execute it.

so it's not a lost cause

The background is actually the SOI, if you zoom out with the orbit, eventually you will see it change.

Link to comment
Share on other sites

  On 8/30/2018 at 10:44 PM, linuxgurugamer said:

Thinking about it, I think I can get some code from GravityTurn which will do most of what I would need to both do the maneuver and to set the maneuver node AND to tell mechjeb to execute it.

so it's not a lost cause

The background is actually the SOI, if you zoom out with the orbit, eventually you will see it change.

Expand  

Just an update:

I've added settings for the SOI color in both the editor and flight

I've added buttons to grab either the current Pe or Ap from the active vessel when in flight

I'm working on the code to perform a maneuver at the selected Pe/Ap to get into the desired orbit.  Once that's done, I'll probably add what's needed to have MechJeb perform the maneuver.  To do this, I've copied the minimal amount of code from both MechJeb and GravityTurn. 

Hard to say when I'll get this done, I'm shooting for tomorrow evening, but have a lot to do outside of this.  

Link to comment
Share on other sites

  On 8/30/2018 at 1:28 PM, eberkain said:

I've seen people refer to using matlab, which this looks like a plugin for that.  I've never took the time to learn how to use it because it looks so intimidating, I want a for-dummies version where I can just plugin my destination and the gravity assist body and then have it calculate a launch window.  

Expand  

Yes, but ... which window?  The problem you encounter is that there are too many variables.  You have to consider not only your destination and the assisting body, but also the time of departure, duration of flight, initial delta-V expenditure, braking delta-V expenditure, and provisions for return--which may not be for years if you need an assist to get back.  Seeking a path to orbital synchronicity between satellites that have the exact same major orbital characteristics (the only real difference being the time of periapsis passage) is easy compared to seeking something similar from at least three different celestial bodies that not only move at different speeds and directions, but also effect changes to your flight path merely by existing.

  On 8/30/2018 at 3:36 PM, linuxgurugamer said:

I looked (briefly) into the FlybyFinder with an eye towards making it a native mod.  But it's written in what appears to be a form of Pascal, which isn't a killer, but then looking at the instructions on how to use it just made me shudder

Expand  

Heh.  FlybyFinder can be a powerful tool, but it is emphatically not intuitive.  It's gotten me out of some otherwise impossible situations, but I don't even want to guess at what kind of evil voodoo you'd need to resort to doing to make it work in-game.

However, and in the interests of keeping something on topic, I do have a more functional observation:  on the subject of things that involve both fantastically non-intuitive calculations and resonant orbits, I often plan my satellite networks using multiple independent craft.  Normally, this is for reasons of utility:  I sent a scanner to the Mun; now that the scan is done, I can re-purpose it into a relay.  Alternatively, I send up my Kerbin relays early in career when I don't have the money or the engines to launch a complicated tri- or quad-payload and instead must resort to sending one relay at a time.  To synchronise these, I find the phase angle and take the difference I need to get 120° separation (I prefer trigonal planar networks).  That usually necessitates calculating resonant orbits with obnoxious ratios such as 477/360 and other, similar fun.  Would it be possible for this plugin to give an orbit based on the desired resonance rather than the number of satellites in a regular polygon?

Edited by Zhetaan
Link to comment
Share on other sites

  On 8/31/2018 at 5:20 PM, Zhetaan said:

Heh.  FlybyFinder can be a powerful tool, but it is emphatically not intuitive.  It's gotten me out of some otherwise impossible situations, but I don't even want to guess at what kind of evil voodoo you'd need to resort to doing to make it work in-game

Expand  

Making it work (ie. Rewriting it in c#) isn't difficult.  But making it easy to use is.

 

  On 8/31/2018 at 5:20 PM, Zhetaan said:

Would it be possible for this plugin to give an orbit based on the desired resonance rather than the number of satellites in a regular polygon

Expand  

No, sorry.  Too far out of scope.

Link to comment
Share on other sites

  On 8/31/2018 at 5:20 PM, Zhetaan said:

Alternatively, I send up my Kerbin relays early in career when I don't have the money or the engines to launch a complicated tri- or quad-payload and instead must resort to sending one relay at a time.  To synchronise these, I find the phase angle and take the difference I need to get 120° separation (I prefer trigonal planar networks).  That usually necessitates calculating resonant orbits with obnoxious ratios such as 477/360 and other, similar fun.

Expand  

I've set up networks with the satellites launched separately, and the way I got them synchronized was to make the new satellite do a close flyby of the old one (just like you'd do for a docking rendezvous), at which point the phase angle is zero, and then use the synchronous orbit calculator in the normal way to go from zero to 120° separation.  No weird ratios needed.

Link to comment
Share on other sites

New release, 0.0.2

  • Added configurable SOI color for editor and flight (two colors, white and dark grey)
  • Added alternate skin
  • Added buttons to get current vessel's Pe or Ap while in flight scene
    • Added button to create maneuver node.  All pre-existing maneuver nodes will be removed
  • Added Mechjeb integration
  • Added button to call Mechjeb to execute maneuver node, button will be red if Pe is below the atmosphere limit
  • Added button to clear all maneuver nodes
  • Added Kerbal Alarm Clock integration
    • Added button to add alarms for the orbital maneuver (if Mechjeb not installed) and for each subsequent satellite seperation 
  • Added hiding of window when UI is hidden (F2)
  • Added optional hiding of window when game is paused

I've also updated the OP 

Edited by linuxgurugamer
Link to comment
Share on other sites

Really useful mod, thanks.

 

This should certainly be a recommended mod for RemoteTech.

 

As you are planning on adding antenna info, a “stable max range”.

 

The other thing that “Visual RemoteTech Planner” https://ryohpops.github.io/kspRemoteTechPlanner/ does is calculate night time period and battery power required. This would be a really useful addition in the VAB, if that’s at all possible.

Link to comment
Share on other sites

  On 9/2/2018 at 10:53 AM, Cooper42 said:

As you are planning on adding antenna info, a “stable max range”.

 

The other thing that “Visual RemoteTech Planner” https://ryohpops.github.io/kspRemoteTechPlanner/ does is calculate night time period and battery power required. This would be a really useful addition in the VAB, if that’s at all possible.

Expand  

There's already mods that allow calculation of antenna strength/coverage, and power consumption through orbital shadows (one of which is maintained by LGG already); knowing LGG's usual stance, I suspect he'll simply suggest you try using those, rather than duplicate them in this mod. Check them out, maybe they'll do exactly what you need?

 

Edited by JH4C
Link to comment
Share on other sites

  On 9/1/2018 at 8:46 PM, linuxgurugamer said:

Added button to clear all maneuver nodes

Expand  

This one is bugged. The actual maneuver will be removed but the patched conic and the maneuver node symbol will remain (the symbol will 'float' and moves around when moving the camera). The symbol even persists after switching to the main menu.

wzMb6YR.png

Tested in KSP 1.4.5 in my regular install and a clean install.

I should mention, that there is no log entry for deleting the node but there is one for creating it. Nothing else to mention in the log, but I've uploaded it for you anyway: https://www.dropbox.com/s/0nhsgciymfnnuaf/output_log(ROC).txt?dl=0
(I've typed 'The node is already deleted but there is no log entry' into the console to mark the spot in the log^^)

Link to comment
Share on other sites

  On 9/2/2018 at 10:13 PM, 4x4cheesecake said:

This one is bugged. The actual maneuver will be removed but the patched conic and the maneuver node symbol will remain (the symbol will 'float' and moves around when moving the camera). The symbol even persists after switching to the main menu.

wzMb6YR.png

Tested in KSP 1.4.5 in my regular install and a clean install.

I should mention, that there is no log entry for deleting the node but there is one for creating it. Nothing else to mention in the log, but I've uploaded it for you anyway: https://www.dropbox.com/s/0nhsgciymfnnuaf/output_log(ROC).txt?dl=0
(I've typed 'The node is already deleted but there is no log entry' into the console to mark the spot in the log^^)

Expand  

I'll look at it, it might need to wait a few days, I'm on a vacation right now.  I'll dig into it later this evening, I think I know what's going on

Link to comment
Share on other sites

  On 9/2/2018 at 10:53 PM, linuxgurugamer said:

I'll look at it, it might need to wait a few days, I'm on a vacation right now.  I'll dig into it later this evening, I think I know what's going on

Expand  

I have some other code to compare, maybe I'll find a solution before you do :D

Ok, probably not and right now I'm working on a more subtile issue of precise maneuver but this is fun :)

Link to comment
Share on other sites

@linuxgurugamer I found a solution, how about you? :D

if (GUILayout.Button("Clear all nodes"))
{
	for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0 ; i--)
	{
		FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf();
	}
}

The loop will adress all maneuver nodes of the active vessel and deletes all of them (beginning with the latest node)

Maybe you will find a better solution but it works for me so far :)

edit: If you are interested: I've also edited a minor detail in the alarm creation for KAC. The way you do it (and precise maneuver as well) will end in these alarm details:
r5wx0Ss.png
 

'Time to Alarm' and 'Time to Event' are the same and both are 1 minute ahead of the actual node.

But by adding a alarm margin of 1 minute, the result become a little bit more accurate:
pen12fz.png

Now, 'Time to Alarm' is 1 minute ahead of the node AND the 'Time to Event'.

Like I said, it is just a minor detail and 2 (identical) lines of additional code, but if you don't mind, I would open a PR for both changes (delete all nodes & alarm timings) :)

Edited by 4x4cheesecake
Link to comment
Share on other sites

  On 9/3/2018 at 12:19 AM, 4x4cheesecake said:

I found a solution, how about you? :D

if (GUILayout.Button("Clear all nodes"))
{
	for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0 ; i--)
	{
		FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf();
	}
}

The loop will adress all maneuver nodes of the active vessel and deletes all of them (beginning with the latest node)

Expand  

Same solution I have, I got it from MechJeb.

  On 9/3/2018 at 12:19 AM, 4x4cheesecake said:

Now, 'Time to Alarm' is 1 minute ahead of the node AND the 'Time to Event'.

Like I said, it is just a minor detail and 2 (identical) lines of additional code, but if you don't mind, I would open a PR for both changes (delete all nodes & alarm timings) 

Expand  

Do the PR, I'll look for it in a few mintues

Thanks

Link to comment
Share on other sites

  On 8/25/2018 at 4:15 PM, zer0Kerbal said:

 

but what day and time is it on the Mun? ;p

Expand  

 

If you use the 12 days of Christmas song; eternal Christmas on the moon.  Is Day 8 Year 51 according to Moon time so 08/51 a little before 6pm at the point of the moon where earth is nearly overhead.

 

Using the same convention as Lunar standard time; time is unknown on the Mun until the first kerbal lands on it; that moment time starts :)

Edited by ToneStack
Link to comment
Share on other sites

Looks like an awesome mod.  I will try it soon.

How much work to make the satellite orbit time the field to set?

I like to have the satellite period be 12 hours, say.  The transfer orbit would then be 16 hours for 3 satellites, 15 hours for 4, 14 hours for 6, etc.  With RCS, I can get my orbits to within a fraction of a second of these values.

RolanCCC 

Edited by Rolan
Typo
Link to comment
Share on other sites

  On 9/7/2018 at 5:08 AM, Rolan said:

Looks like an awesome mod.  I will try it soon.

How much work to make the satellite orbit time the field to set?

I like to have the satellite period be 12 hours, say.  The transfer orbit would then be 16 hours for 3 satellites, 15 hours for 4, 14 hours for 6, etc.  With RCS, I can get my orbits to within a fraction of a second of these values.

RolanCCC 

Expand  

So rather than setting the orbit altitude, you want to set the orbital period?

shouldnt be that hard, I just need t9 find the calculations for determining the altitde from thhe period

Link to comment
Share on other sites

  On 9/7/2018 at 12:07 PM, linuxgurugamer said:

shouldnt be that hard, I just need t9 find the calculations for determining the altitde from thhe period

Expand  

This sounds related to something I was thinking about yesterday:

I'd like to put a ring of relay satellites in solar orbit, probably between Duna and Dres.  Since they'd be coming from Kerbin which is also in solar orbit, instead of raising and lowering the Ap to position the satellites, it'd make more sense to just wait until Kerbin is aligned correctly to send each satellite directly to where it belongs.  I haven't worked through the details yet, but I think it just involves calculating period of my target orbit, comparing against Kerbin's orbital period to find their relative angular speed, and then waiting for 120° of relative separation (or whatever angle, based on the desired number of satellites) before sending the next satellite to the solar orbit.

That's sort of a special case, very different from what this tool currently does, and it's probably out of scope for this mod.  I don't mind just doing the math myself.  But it's something to consider, in case you can think of a good way to add it.

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