# QuestionDetermining distance between docking ports on different vessels

#### dmurley

##### New member
The following question arises in the context of "Go Play in Space," chapter 2:

On the Docking MFD, a distance is shown to the docking port on the other vessel. How is this distance determined?

#### martins

##### Orbiter Founder
Orbiter Founder
For the C++ API, this involves

- retrieving the docking port positions in local vessel coordinates (VESSEL::GetDockParams)
- mapping from local to global frame (VESSEL::Local2Global)
- calculating the Euclidian distance between the two global docking port positions

Since you are asking in the Lua forum, I guess you are more interested in the Lua API. I'm not sure if the required functionality has been completely ported to the Lua interface. If you find that there is a function missing, let me know and I'll look into adding it (or you could do it yourself, since the entire Lua implementation is available in source as part of the Orbitersdk samples).

#### dgatsoulis

##### ele2png user
... I'm not sure if the required functionality has been completely ported to the Lua interface...

kuddel has added local2global to the Lua API. If the OP (or anyone else) is interested, the extended Lua API is here.

#### kuddel

##### Donator
Donator
I also have a Lua example doing just that (show distance from one docking port to another)
lying around at home. I'll post it once I'm back from office.

#### kuddel

##### Donator
Donator
...and here it is.

You can take a look at Script\Test\undock_test.lua for one possible "solution".

I am sure that this Scenario/Script combination works for Orbiter BETA, possibly also with Orbiter 2016... -haven't tried-...just try the scenario and see

The whole idea behind this package started from this thread.

#### Attachments

• LuaTest_Scenario.zip
2.9 KB · Views: 3
Last edited:

#### kuddel

##### Donator
Donator
kuddel has added local2global to the Lua API.
Side-note: If both vessels orbit the same body, I would recommend to use vessel::local2rel.

Last edited:

#### dmurley

##### New member
It will probably be late tomorrow (my time) before I can look at the example you posted. I'll let you know if I have questions.

By the way, how *do* you attach files to your posts (another newbie question)? Is zip format pretty standard when you do this?

#### dbeachy1

Orbiter Contributor
Donator
Beta Tester
By the way, how *do* you attach files to your posts (another newbie question)? Is zip format pretty standard when you do this?

In the "Additional Options" section below the main section where you type your reply, there is a "Manage Attachments" button. Valid attachment extensions are listed there:

Valid file extensions: bmp cfg doc gif jpe jpeg jpg log pdf png psd scn txt zip

There are maximum size limits for each file type, however. For zip files, the max size is 5.77 MB. If you need to attach a large item to a post, you can use something like Dropbox to host it externally and then include a link to the content in your post.

#### dmurley

##### New member
I am trying to run the local2global() Lua function and keep getting an execution error when I try to invoke that function. The code I am using is the following:

Code:
pos1,dir1,rot1=hGL1:get_dockparams(dPrt1)
pos2,dir2,rot2=hGL2:get_dockparams(dPrt2)
term.out (pos1)
term.out (pos2)
gpos1=hGL1:local2global(pos1)

pos1 and pos 2 print out ok. The execution error occurs when local2global() is invoked. I have assumed invocation parameters based on what was sent to me in an example and I don't see what the problem could be (do I need to compile the Lua beta functions before I can use them? I don't have a C++ compiler).

Any comment would be appreciated. Thanks.

(After reading the post above, I realized that I should mention that I'm using Orbiter 2016 instead of Orbiter Beta. That may be my problem.)

Last edited:

#### dgatsoulis

##### ele2png user
If you want to use local2global in Orbiter2016, you need to install the .dlls from the link on post #3 of this thread, in your Orbiter2016 installation.

Unzip the LuaScript 2017-12-07(dlls).zip in your Orbiter2016 directory, let it overwrite the current files and everything will go in its place.

#### dmurley

##### New member

When I extracted the files from LuaScript 2017-12-07(dlls).zip into "C:/Orbiter 2016" in order to get the Lua beta functions, Lua quit working and I got the error message in the attached file. This makes me think that I am doing something wrong. Any ideas? Thanks.

#### Attachments

• error.jpg
23.8 KB · Views: 10

#### kuddel

##### Donator
Donator
That package (ZIP) was made for Orbiter BETA, so Orbiter 2016 might not work.
I'll see if I can provide something that can be used with Orbiter 2016.
But I can't promise anything yet, one or two methods/features might not be present in Orbiter 2016.
...stay tuned.

#### martins

##### Orbiter Founder
Orbiter Founder
Also, I should say sorry that I haven't incorporated your extensions into the beta distribution yet, kuddel. At the time the problem was that some of the code wouldn't compile under VS2008 which I was using then, but since switching to VS2015 I don't really have any excuses left. Hopefully I'll find some time soon.

If I remember correctly, the only thing missing was the documentation for the new functions. I'll see if I can add those.

#### kuddel

##### Donator
Donator
Hi Martin, as far as I remember most of the functions have been incorporated in the BETA repository already...do you have a co-worker you forgot to pay?

Some (minor) things have not been incorporated, but all the methods/functions are already in there.

I also fixed some very minor (documentation fixes) that might also be nice to be incorporated.
I'll post an updated package when it's ready for easy integration.

#### martins

##### Orbiter Founder
Orbiter Founder
...do you have a co-worker you forgot to pay?
I don't think so, unless I've forgotten them too - that would be a worry :lol:

Some (minor) things have not been incorporated, but all the methods/functions are already in there.
Excellent. I love things on my to do list that get so fed up with my working speed that they fix themselves. It doesn't happen often enough ...

Anyway, there definitely was something that I didn't manage to incorporate. It may have been some fixes of the terminal window, but I'm no longer sure about it.

#### kuddel

##### Donator
Donator
LuaScriptPlus DLLs (for Orbiter 2016)

Yeah, terminal window needs some more love.

---------- Post added at 21:21 ---------- Previous post was at 20:47 ----------

@dmurley: I've uploaded versions for Orbiter 2016 (see attachments in first post of development thread).
You may try those. Note, that the contents of the ZIP will overwrite your files, so you might like to backup those before they get overwritten.

The test scenario (\Scenarios\Tests\undock_test.scn) is a starting point to run the test script.
As Orbiter 2016 does not have the "automatic Lua script start from scenario" feature, you have to run/start that manually.
At the LuaConsole type:
Code:
run('test/undock_test')

Have fun (if it works for you, else please report back)

Last edited:

#### dmurley

##### New member
kuddel: no hurry. I have plenty to keep me busy and lots to learn. Let me know when you have something you want me to try. Thanks for your help and patience.

#### kuddel

##### Donator
Donator
kuddel: no hurry.
What, me hurry?

Let me know when you have something you want me to try.
Hmm...I don't get it !? ...The thing in my previous post, that's something I would like you to try.

#### Urwumpe

##### Not funny anymore
Donator
I don't think so, unless I've forgotten them too - that would be a worry :lol:

No post-grads around? Usually they are the most expendable resource in a university.

I remember one, whose PhD got constantly delayed by various reasons and rules, though everybody knew he was simply too hard to replace for the faculty. :lol:

Replies
7
Views
608
Replies
31
Views
994
Replies
137
Views
3K
Replies
6
Views
222
Replies
2
Views
182