Controlling Celestia from another application

Have a question about using Celestia? Check here first for FAQs and helpful advice.
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Topic author
davekp
Posts: 3
Joined: 30.12.2017
With us: 6 years 10 months

Controlling Celestia from another application

Post #1by davekp » 30.12.2017, 00:53

Hi Folks,

I'm new to Celestia and would like to try something a bit different. If this is an easy or at least doable thing, please let me know.

I would like to control Celestia from a different program. I'm working on a game. The idea would be to write a helm console in C# or some other language and from that, control the view, apparent movement, etc. that is visible on the Celestia window.

At a guess, I suspect I'm not the first person to ask this, but I wasn't sure what to search on to find previous posts.

Thanks in advance!

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #2by selden » 30.12.2017, 10:08

Other programs can interact with Celestia using various forms of inter-process communication. Depending on how Celestia is installed, commands can be sent by constructing a textual command line. (e.g. celestia --url "command" ). More sophisticated methods use IPC libraries written in Lua for Celestia.

I have a vague recollection of someone posting on the Celestia Forum some years ago about a project using Celestia as the visualization component of a simulation system. Here's one, although it's not the one I was thinking about: viewtopic.php?f=9&t=13350

Using these search terms with Google to search ESA's conference organization site turned up several papers about such projects involving the use of Celestia:
celestia site:indico.esa.int

Here's a paper on the SimBridge project, for example: https://indico.esa.int/indico/event/93/session/4/material/0/4.pdf
There seem to be several similar papers submitted to Simulation and EGSE for Space Programmes (SESP2015) (event/93)

OpenSimKit provides some IPC features optimized for Celestia. See http://opensimkit.org/ and http://opensimkit.org/resources/FCXNL-10A08-1864803-1-1864803witt.pdf
Selden

Janus
Posts: 537
Joined: 13.08.2016
With us: 8 years 3 months

Post #3by Janus » 30.12.2017, 13:19

What I did when I setup a Kinect controlled display for someone was simply run my kinect interfaced in the background, then inject keyboard commands which celestia as the active running program in focus would receive.

One problem you will have with celestia is that when it is not the focus, it does not always run.
When minimized, or backgrounded, it is also paused.
So standard interprocess communication may not work as you would expect.

The reason for this is that the only loop in the display loop.
Script interpretation, timers, file access, IO, all of these only occur during display loops.
All messages are buffered/stored during a display loop, then processed on the next one.

While this works great at 60+ FPS, timers can not tell they were paused, nor can script processes.
I discovered when helping someone with world design.
I wrote a script to highlight airs of stars of particular combinations within certain distances.
I started the script, watched it for a few minutes, calculated a running time of four hours, left it running and went on to other things.
Once it gotten covered over by other tasks, it no longer ran.
Quite frustrating.
Lesson learned though.
Even had to disable screen saver, quite the mess.

Just so you know.


Janus.

Topic author
davekp
Posts: 3
Joined: 30.12.2017
With us: 6 years 10 months

Post #4by davekp » 02.01.2018, 04:18

Some good information! Thanks. I'll follow up these leads!

Added after 6 minutes 15 seconds:
Ok, here's another question for the same project. In Celestia you can set how much time it takes to move to an object. What I would like to do is set a velocity. In order to do that I need to either:

1 - Set velocity.
2 - Determine distance to the object and calculate time based on the velocity I want...and then set the time.

So can I read values (like distance from current location to an object) from Celestia? Or can I set a velocity for motion?

Added after 20 minutes 19 seconds:
Oh...never mind the speed question. I see it. /blush

Janus
Posts: 537
Joined: 13.08.2016
With us: 8 years 3 months

Post #5by Janus » 02.01.2018, 05:00

@davekp

The first thing to remember is that in Celestia, the only thing that moves in a user controlled manner, is/are the OBS window(s).

Basically there are two modes.

You are either following something, such as a planet/moon/asteroid/comet, and Celestia will keep your view window stationary relative to it.
Or you are stationary, and watching the universe go by.

These can most easily be illustrated this way.

Fire up celestia.
Hit enter.
type 'phobos', hit enter.
hit 'g', to go to phobos.

Upon arrival, watch for several seconds how it stays still.
This is mode one above, you in sync with the universe.

Now hit escape, the 'Esc' key on the upper left.
Notice it runs away, that is mode two above, you are stationary, but the universe moves on without you.

I am afraid there is no method for you to set Phobos' speed, or anything else.

The clock and how you observe are the only two things you get to play with.
It is a recreation of what is, not a simulator of what can be.

I have been tinkering with adding objects that I can move though.
However, keeping everything in sync with everything else and doing collision detection is a pain.
The constant moving frame of reference requires some unusual coding to overcome.

In addition, getting the attributes of the closest items in order to determine their mass/gravity in real time has an impact on overall performance.
Displaying an item's real path with gravity included, hard, especially when it has its own thrust, such as where do I aim a rocket to hit something, has many layers of calculation that have to be and stay synced, is hard.

The problem is that though Celestia has the masses of most everything, it does use any of it.
The orbits are defined from real observations(vsopt87), not mass calculations.
So you see, messy is just the warm up.

I hope I have covered/answered your question.

If not, then ask again slightly differently, and I or a real programmer can try again.


Janus.

Topic author
davekp
Posts: 3
Joined: 30.12.2017
With us: 6 years 10 months

Post #6by davekp » 02.01.2018, 05:35

Actually, both of you have been very helpful! Velocity can be controlled with the A, Z and F1 - F7 keys. You don't get a lot of control with them...but hey...not what it was made for. I think I can make good use of what's there!


Return to “Help Central”