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!
Controlling Celestia from another application
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.
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.
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
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
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.
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.
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
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
@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.
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.