# ScenarioStation-keeping at Earth-Moon L2 scenario example

#### MontBlanc2012

##### Member
Following directly on from An update on all things Lissajous and Halo, attached is a zip file containing a scenario and associated script and data files for a demonstration scenario of station-keeping at Earth-Moon L2 Lagrange point.

Download the zip file and, in the usual file, copy the files into the relevant Orbiter directories. Then:

* open Orbiter and run the 'EML2.scn' scenario;

* open the Lua Console using the Scenario Editor and type <run 'Lissajous/EML2'>

You should now have two stock Delta-Gliders docked to each other at Earth-Moon L2. The motion of one of the Delta-Gliders ('GL-NT') is 'slaved' to EML2 and will remain firmly anchored to the Lagrange point even at high time acceleration. The motion of the other Delta-Glider ('GL-01') is unconstrained and can be manoeuvred at will. It will not, however, remain at the L2 Lagrange point without active station-keeping on your part.

In the top right-hand portion of the screen you should see some blue text recording the cumulative amount of station-keeping dV required to keep GL-NT on-station at the Lagrange point. If you do not see this, the station-keeping script has not been loaded correctly.

Enjoy.

#### Attachments

• Station-keeping EML2.zip
442.4 KB · Views: 10
Last edited:

#### gattispilot

So how hard would it be to do this for Satellites?

#### MontBlanc2012

##### Member
So how hard would it be to do this for Satellites?

Not quite sure what you mean. Delta-Glider's were used in the posted scenario simply because they are stock - so anyone should be able to run the file. But the same algorithm can be applied to any vessel.

If you look in the 'Script/Lissajous' directory, you'll find a file called 'EML2.lua'. If you open this in a text editor, near the bottom of the file, you'll see a few lines that read:

Code:
local base    = "Script/Lissajous/Earth-Moon/EM L2 - Lissajous - ER3BP - "
local sys     = "Earth-Moon"
local v       = vessel.get_interface("GL-NT")

The last of these lines references "GL-NT", which is the name of the Delta-Glider that is being 'slaved' to L2. Change the reference to a different vessel and that vessel will be slaved to L2 instead.

(The other two lines of code simply provide references to the appropriate dataset. For example, if you want to slave the motion to L1, simply change the first line to:

Code:
local base    = "Script/Lissajous/Earth-Moon/EM L1 - Lissajous - ER3BP - "

#### Notebook

News Reporter
Donator
Hello MontBlanc2012.

I've installed the files, but getting a "Execution Error"? in Lua Console.

N.

#### gattispilot

I was thinking for this my Queqiao in part of the Change4 project. As I believe the satellite was placed there?

So can only 1 vessel be placed there or does it need that slave vessel?

#### MontBlanc2012

##### Member
Hello MontBlanc2012.

I've installed the files, but getting a "Execution Error"? in Lua Console.

N.

Hmmm. I've just downloaded the .zip and installed on my Orbiter installation. Opened Lua Console and typed in:

Code:
%run 'Lissajous/EML2'

All works fine at my end. Can you check your installation and the Lua Console command? Thanks

MB

Last edited:

#### Notebook

News Reporter
Donator
Its fine, I was putting in the <> characters.

Thanks, N.

#### MontBlanc2012

##### Member
I was thinking for this my Queqiao in part of the Change4 project. As I believe the satellite was placed there?

So can only 1 vessel be placed there or does it need that slave vessel?

Any number of vessels can be 'locked' to L2. However, the routine slaves each vessel to L2 with sub-millimetre precision (such is the power of floating point arithmetic). To lock two or more vessels to L2, and to avoid a non-physical overlap, one would need to add a small spatial offset to the position of the vessels. But this is an easy adjustment to make.

#### gattispilot

I will give her a try. then try to put my satellite there

---------- Post added at 08:17 PM ---------- Previous post was at 09:41 AM ----------

I guess I need the Lua Console

#### MontBlanc2012

##### Member
Code:
I guess I need the Lua Console

Yes, I'm afraid so. It should be simply be a matter of going to the 'Modules' pane and checking the 'LuaConsole' box. Then, when Orbiter is running, Lua Console should be accessible via the 'function' button at the top of the screen and should appear as one of the listed 'custom functions'.

[As an aside, using Lua here to run this station-keeping algorithm probably isn't state-of-the-art and a more robust housing would be via Orbiter's C/C++ api interface. However, this scenario was intended as a simple demonstration piece using a straightforward, and easy to build, application of the Lua api interface. It works, but it isn't pretty.]

Last edited:

#### gattispilot

Thanks. But I got that Execution Error

But I am not sure if installed correctly

---------- Post added at 09:02 PM ---------- Previous post was at 08:35 PM ----------

Got it to work

So I t edited the script
Code:
local base    = "Script/Lissajous/Earth-Moon/EM L2 - Lissajous - ER3BP - "
local sys     = "Earth-Moon"
local v       = vessel.get_interface("Queqiao")
and saved as EMQL2

So will place the Queqiao at the L2 position?

#### MontBlanc2012

##### Member
Code:
Thanks. But I got that Execution Error

But I am not sure if installed correctly

Chances are that you didn't install correctly. The 'EML2.scn' file needs to be appear directly under the 'Scenarios' directory in your installation; and the whole of the 'Lissajous' directory needs to be copied over so that the Lissajous directory now appears directly under the 'Script' directory in your Orbiter installation. In other words, you need to preserve the directory structure of the entire contents of the .zip file when you copy things over.

When running the Lua Console script, it is important to type in the correct command (as Notebook discovered). At the prompt, type:

Code:
%run 'Lissajous/EML2'

(N.B., Here, the '%' is the prompt , so you don't type that in.)

---------- Post added at 03:06 AM ---------- Previous post was at 03:04 AM ----------

Code:
So I t edited the script
Code:
local base    = "Script/Lissajous/Earth-Moon/EM L2 - Lissajous - ER3BP - "
local sys     = "Earth-Moon"
local v       = vessel.get_interface("Queqiao")
and saved as EMQL2

So will place the Queqiao at the L2 position?

So long as there is a vessel 'Queqiao' in your scenario available to move to EM L2, then, yes, it will lock that vessel to the Lagrange point.

#### gattispilot

Thanks. So how would I /can I distribute it in an addon? For me it may be just place the satellite at the L2 spot. So the scn would start with the satellite at L2. For the Change4 it is really for looks.

#### MontBlanc2012

##### Member
anks. So how would I /can I distribute it in an addon? For me it may be just place the satellite at the L2 spot. So the scn would start with the satellite at L2. For the Change4 it is really for looks.

Sorry for the slow reply. I was flying most of yesterday and finally arrived at the hotel way too late for me to write a response.

In principle, one can get a scenario to auto run a Lau script. And, indeed, I’ve tried running these scripts in this fashion. However, these scripts are very precise in what they do and need to run in a very particular way: each time the core routines are run, Orbiter needs to suspend momentarily its standards time-stepping algorithm so that all of the script’s computations can be completed and replace the vessel at the right spot. Then control is handed back to Orbiter so that it can continue doing its simulation until the next time the script needs to run the core routines to update the location of the vessel. This interruption occurs about once a second at low time accelerations and about 10 times a (real world) second at high time accelerations. When trying to automate running the script using the standard command set provided by Orbiter, the process control of the script changes so that the script appears to be run as a background task rather than the primary control task. This results in the vessel not being placed at the right location and, instead of being placed with sub-millimeter accuracy, large and erratic errors of 10-100 meters in placement of the vessel ensue. Not ideal.

At the moment, I don’t know how to get around this loss of process control issue. I’m sure there is a way of doing it - I just haven’t worked out how to do it yet. When I have a solution, I’ll let you know.

Replies
26
Views
2K
Replies
0
Views
1K
Replies
6
Views
426
Replies
5
Views
452
Replies
5
Views
577