Jump to content

[1.12.x] KSP Resonant Orbit Calculator


linuxgurugamer

Recommended Posts

10 minutes ago, 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.

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

14 minutes ago, 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.

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

15 hours ago, 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.

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 9:28 AM, 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.  

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 11:36 AM, 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

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

28 minutes ago, 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

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

 

30 minutes ago, 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

No, sorry.  Too far out of scope.

Link to comment
Share on other sites

11 hours ago, 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.

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

1 hour ago, 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.

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 10:46 PM, linuxgurugamer said:

Added button to clear all maneuver nodes

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

38 minutes ago, 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^^)

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

3 minutes ago, 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

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

35 minutes ago, 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)

Same solution I have, I got it from MechJeb.

37 minutes ago, 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) 

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 9:15 AM, zer0Kerbal said:

 

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

 

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

6 hours ago, 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 

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

37 minutes ago, linuxgurugamer said:

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

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

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