LEO targeting - a numerical tool for orbital maneuvering planning

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
I'm happy to present the first version of LEO targeting, a C++ tool to analyze orbits and compute orbital maneuvering burn plans.

The tool does numerical solutions of trajectories in J3 gravity with an ellipsoid earth shape, finite duration burns both with given Delta v (PEG-7) or using PEG-4 targeting and constrained optimization (for instance it can do questions like 'What's the most propellant-efficient ignition time for a PEG-4 de-orbiting solution assuming I want a range of 3600 miles from entry interface to landing site from my current eccentric orbit?')

I believe this may not only be of use for my Flightgear Shuttle project but also for the Orbiter community.

To illustrate the things numerical orbital dynamics does - here's a test computing the stability analysis for a Molniya orbit where a 63.4 inclination is stable against the J2 perturbation and has a periodically varying argument of the periapsis whereas changing the inclination to 53.4 degrees gives rise to a drift of the parameter.

molniya_periapsis_drift.jpg


There's a manual provided with the code, and I'm in the process of adding tutorials for interesting problems to the website.

The software is licensed under the terms of the GPL 2+.

Download the source code from here

There is no executable provided (I'm working under Linux and can't compile for Windows) - anyone who wants to create a Windows binary is cordially invited to do so, and I'll be happy to host the file on my website. As far as I'm aware there's only standard C++ libs used, so it should compile fine cross-platform.

The tool is not extensively tested, I proceed according to the free software philosophy 'release early' in the hope that more eyes are better in bug-spotting, so feedback (and patches) are welcome.

I plan to develop this further to assist rendezvous computations as well, so there'll be more than just optimized insertion and de-orbit solutions.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
Here is a quick compile for Windows with VS2015 (including the VS solution/project): https://snoopie.at/face/beta/leo_targeting.Windows.zip

The source is almost untouched, just had to add this to state_vector.cxx at the top for "or" to work:
Code:
#include <iso646.h>
Lacking a test-suite, I don't know if everything is working properly, but I ran the included config files, and they look good. Molniya.dat in Excel with XY-plot looks like so:
molniya.png
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
The source is almost untouched, just had to add this to state_vector.cxx at the top for "or" to work:

This looks like a mistake from my side (coding habits from a different language creeping in...) - there's no reason to use 'or' that way and I think the best solution is to simply change every instance to '||'.

I'm kind of surprised my compiler just swallowed this...

I'll try to keep the sources clean of this.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
This looks like a mistake from my side (coding habits from a different language creeping in...) - there's no reason to use 'or' that way and I think the best solution is to simply change every instance to '||'.

I'm kind of surprised my compiler just swallowed this...

I'll try to keep the sources clean of this.

Looks like a typical Microsoft thing: https://en.wikipedia.org/wiki/C_alternative_tokens
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
@Face:

Three cheers to Microsoft...

I've taken the liberty of hosting the package you compiled (if you object, please let me know and I'll remove it).

@All:

Here is another benchmark result (also in the tutorials) - numerical drift of the longitude of the ascending node compared with analytical mean drift over a couple of orbits:


asc_node.jpg


Reliably makes me happy when analytical benchmarks come out okay...
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
I've taken the liberty of hosting the package you compiled (if you object, please let me know and I'll remove it).

No problem at all, I hope it helps. :tiphat:
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
Quick status update: I've now brought the tutorial series to the point that it reflects most of what the software currently does (in particular the optimized insertion and de-orbit fits).

I'll now work a bit on the code again, in particular a user-controlled acceleration model (perhaps even a realistic one using the rocket equation) and other sources of orbital perturbations would be nice to have.

If anyone has feature requests (sorry, no interplanetary transfer) that'd be a good opportunity.
 

Wolf

Donator
Donator
Joined
Feb 10, 2008
Messages
1,091
Reaction score
11
Points
38
Location
Milan
Thorsten pardon me if my request is non-sense and or not-doable but would it be possible for you to make a generic addon for Orbiter ships (or maybe just for the Shuttle) out of this tool?
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
I can't do that for the simple reason that Orbiter is located in the Windows universe and I work under Linux - so there's no way I can compile and test stuff using the Orbiter API.

(I have a Windows environment to run stuff, but zero development tools installed and zero experience doing that).

Also, I want this code to be firmly OpenSource - which might run into licensing issues with the much more restrictive licensing of the Orbiter core (would need to study the details if the API and some legal texts to be sure..)

I will add the capacity to simulate the properties of other ships, so you will be able to do offline planning for different acceleration capabilities, ISP, thust, dry and propellant mass.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
Also, I want this code to be firmly OpenSource - which might run into licensing issues with the much more restrictive licensing of the Orbiter core (would need to study the details if the API and some legal texts to be sure..)

If you do plain GPL addons, you are practically outlawed here, although Martin himself said that he is fine with it. LGPL should be fine, though.

But I don't get what an actual addon should do here? Why should it bind to the OAPI?
 

ADSWNJ

Scientist
Addon Developer
Joined
Aug 5, 2011
Messages
1,667
Reaction score
3
Points
38
I went back through that epic thread, and re-acquainted myself with the arguments why GPL is fine if you don't want people re-distributing your open source into their closed source, and why LGPL is fine if you don't mind either way. It took me 400+ posts to get there, sadly!

TL;DR developers please publish your source so your addons survive in this community.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
TL;DR developers please publish your source so your addons survive in this community.

That doesn't help much if you don't recommend a license :lol: . On that matter, if you close your source completely you have the least problems here. If you open them completely (like with MIT), too.
On the survival, it depends on the point of view (like so often): if you are the developer, your addon has highest chance of "survival" if it manages to bind many other developers into your walled garden. Points in case: middle-wares like SC4, OrbiterSound or UMmu. Of course "survival" here means just that people have to desperately clench it even if it is long outdated, because they lack a good alternative due to closed sources.

In Thorsten's case here, I'd recommend to do the classic avoid-GPL-dance: create either a strictly closed-sourced, or a completely open-sourced (e.g. MIT) thin proxy from the Orbiter process to the calculation tool process. This way he can keep the development isolated (calculation project developed in Linux, thin proxy/launcher/UI in Windows) and can keep the calculation project GPL license without too much worries.

If the use of the OAPI even makes sense (like I questioned above), that is.
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
It took me 400+ posts to get there, sadly!

The Free Software Foundation has a good summary on the arguments for GPL vs. LGPL:

https://www.gnu.org/licenses/why-not-lgpl.html

I believe in OpenSource licensing because I know I'm not irreplacable - neither am I the best person to design all aspects of some code, nor can I guarantee to be always available, nor do I have the best resources that could be had. Nor do I in fact forsee all applications a piece of code might have...

Good things have happened in the past when industry started to use GPL-licensed projects in terms of plenty of good development flowing back. Bad things have happened in the past when the sole owner of a closed source had an accident (goes by the name of 'bus factor' - how many people do you have sitting in a bus that has an accident to kill some project).
 
Last edited:

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,017
Reaction score
1,254
Points
188
Location
Dallas, TX
Also, I want this code to be firmly OpenSource - which might run into licensing issues with the much more restrictive licensing of the Orbiter core (would need to study the details if the API and some legal texts to be sure..)

Well, IANAL, but I don't think there would be any actual licensing issues here assuming the coderemains under the GPL. As long as you don't use any APIs provided only by GPL libraries (as opposed to standardized C++ libraries with both GPLed and proprietary implementations) in your own code, then there is, guaranteed, no legal trouble you would run into developing an Orbiter addon from your code yourself.

The gnarly bit is where other people integrate your code into Orbiter addons, or if you use GPL-only APIs in your code. Then there get to be some uncertainties as to how the stuff about linking in the GPL actually applies. While I personally don't believe that there would be any problem, many addon developers aren't quite so confident, and might avoid incorporating your code into any Orbiter addon for fear of falling afoul of the GPL. One solution for the case where your code uses no GPL-only APIs would be to use the LGPL, another would be to make a clear public statement about how you, the copyright holder for your code, intend to interpret the GPL when it comes to use of your code in Orbiter addons.

If your code has GPL dependencies written by others, I don't think you would be violating the GPL to use your code in an addon, but the developer of said dependencies might not see it that way, and might try to sue, even though I believe they'd be unable to win (again, IANAL)
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
As long as you don't use any APIs provided only by GPL libraries (as opposed to standardized C++ libraries with both GPLed and proprietary implementations) in your own code, then there is, guaranteed, no legal trouble you would run into developing an Orbiter addon from your code yourself.

This is guaranteed already? Do you have a link?

Last I know is that there are many opinions on that, but no definite statement besides Martin's shrugging of shoulders. Especially regarding the distribution of such addons, i.e. uploading to OHM. I don't know if the idea of the common Orbiter license or the license chooser tool in OHM came into existence, though.

So if your only concern is that Orbiter's developer doesn't get upset due to you developing GPLed addons, you are indeed pretty safe IMHO.
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
then there is, guaranteed, no legal trouble you would run into developing an Orbiter addon from your code yourself.

Since I am the copyright holder of my own code and it's up to the copyright holder to care for enforcing the license, this would seem self-evident (as long as no other person adds to the code).

But in fact the vision / hope I have is that this goes the piece of other GPL codes and potentially finds other interested developers who contribute bits and pieces, or that it gets used by teachers or even in research environments.

My primary motivation or goal is not to provide an Orbiter addon - it's to supply a planning tool for my FG Space Shuttle project making up for the fact that there's no MCC in the sim with the hope to provide a more generally useful GPL tool. This could be equally useful for Orbiter and I'm happy to share and take feature requests, but not to the point that I license the code such that it can be more easily be used in a closed source environment or allows other developers to take pieces and close them off.

I hope that makes it clear.

Edit: For anyone interested in an overview of licensing questions, here's the human-readable FAQ I've compiled for the Flightgear project:

https://forum.flightgear.org/viewtopic.php?f=42&t=29731&p=287613#p287614

(the text has been proof-read by several other project members, including FSF members and people who also work in Linux distribution projects, so I believe it is fairly sound)
 
Last edited:

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
This could be equally useful for Orbiter and I'm happy to share and take feature requests, but not to the point that I license the code such that it can be more easily be used in a closed source environment or allows other developers to take pieces and close them off.

Let's say you create an Orbiter addon that links to the OAPI and your code. Now along comes someone with the notion that GPL is not "applicable" to Orbiter addons anyway, so takes your code and uses it in a closed-source Orbiter addon. What would you do?

I think you can't do anything about it but complaining loudly. I think so because I don't trust the community to respect the GPL on addons anymore. After all, no real-world court would accept a lawsuit based on free-to-begin-with software.

Now you can say that it doesn't matter, at least it was used for Orbiter and you don't have to pay for it. But from your explanations, I guess you won't be happy with that.

That's one of the reasons why my advice would be to not touch the OAPI with GPLed software. Keep it separated.
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
Let's say you create an Orbiter addon that links to the OAPI and your code. Now along comes someone with the notion that GPL is not "applicable" to Orbiter addons anyway, so takes your code and uses it in a closed-source Orbiter addon. What would you do?

The usual chain of escalation: First talk to the person, explaining the license and ask to adhere to it, if that doesn't lead anywhere send a copyright violation note to the server administrator on which the content is located to remove it, and if that doesn't help, write to the FSF, identifying myself as the copyright holder of a GPL-licensed piece of code in need - and they'll look over and if the case is clear, they might do the court proceedings or advise me what to do.

After all, no real-world court would accept a lawsuit based on free-to-begin-with software.

That's where you are wrong - generically violating the terms of the GPL is a copyright violation - and in any legal system where there is copyright protection, there's protection for the GPL. There have been several court cases in which this was solidly established.

Also, GPL software is free as in you can always see the source code, but it can be sold (to people who don't compile themselves or coming with extra support or services - Linux is a good example), so there can even be substantial damages for a copyright violation.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,390
Reaction score
577
Points
153
Location
Vienna
That's where you are wrong - generically violating the terms of the GPL is a copyright violation - and in any legal system where there is copyright protection, there's protection for the GPL.

Well, in theory, practice and theory are the same. In practice, they are not.
I know that in Austria, no judge would accept an Orbiter addon vs. Orbiter addon case based purely on GPL violations, simply because there is no money involved anywhere. Yeah, we are that materialistic here. :lol:

But anyway, it is just an advice. I'll be the first one to applaud a GPL Orbiter addon, and certainly the last one to violate it. Good luck! :cheers:
 

Thorsten

Active member
Joined
Dec 7, 2013
Messages
785
Reaction score
56
Points
43
Well, back from legal niceties to orbital stuff - here's another interesting one - a circularization using an ion-thruster (well, conceptually - if I insert realistic thrust, the orbits are too close to plot, though it does run fine...)

ion_thruster.jpg


The simulation starts out on the periapsis of an eccentric orbit, and the ion thruster fires for an arc around the apoapsis - as a result the periapsis slowly grows. So does the apoapsis, because of course the arc is fairly long, so this is not really an 'at apsis' burn. However, if the threshold is narrowed, the apoapsis growth shrinks as expected (but circularization time grows).

So if anyone has a need for low thrust trajectory simulation, that's going to happen.
 
Top