[Solved] how to do Simulation and realtime visualization

All about writing scripts for Celestia in Lua and the .cel system

Moderator: selden

Re: how to do Simulation and realtime visualization

Postby Stuffer » Wed Jan 21, 2009 9:20 am

Thanks a lot for helping me. My ScriptedOrbit function works. Now I can try to "link" it to my simulation.
Your code was very helpful and understandable.
Though I had to change some things e.g. the n_2+6 --> just n_2

Again I first tried to observe the behaviour of the code in a celx-script. So to me it's very strange why the source-function returned so differently either in a celx-script or a lua-function. That's why at first I was a little confused where this comes from since I'm not that much into programming anyway.
But I'm really glad to see it work now.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB
User avatar
Stuffer
 
Posts: 67
Joined: Wed Dec 03, 2008 7:40 am
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Postby selden » Wed Jan 21, 2009 9:49 am

Stuffer,

You're very welcome.
It's good to know you got it working.
I learned some things myself in the process!

It may be that the difference in the path returned by debug.getinfo when it's called in a Scripted function is a bug.
Certainly the leading @ is not a valid directory specification.
Selden
User avatar
selden
 
Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

Re: how to do Simulation and realtime visualization

Postby Stuffer » Thu Mar 05, 2009 9:27 am

Hi,

My ScriptedOrbit and ScriptedRotation works. But is it possible though that Celestia calls those two functions with a different frequency?
I inserted a counter into both functions and subjectively said I would think that the ScriptedOrbit Counter counts faster than the ScriptedRotation's one.

Is this because of the more functions included into ScriptedRotation?
I observed that the Rotation's counter only starts when going to the s/c by the goto-command.
Can I somehow synchronise them when using both?

Also when I read data from a socket and then use the written variables (defined as table in hookscript) in those functions (just assign them to locals end give those back by return), after some time celestia starts to call those functions less often, so my s/c starts "jumping" from one angle to the next. This is especially with ScriptedRotation active.

Does this have something to do with my RAM? Does Celestia write something into it and it eventually gets full?
I observed that the CPU usage is on 100% even when running Celestia without doing the socket thing. Is my CPU too slow?
I have a 3.4GHz machine here with 1GB RAM and WinXP.
My graphique card is a nVidia Quadro with 128MB.
And I'm using Celestia 1.6 from SVN.

Did such a thing ever occur to anyone else?

Thanks in advance
Stuffer
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB
User avatar
Stuffer
 
Posts: 67
Joined: Wed Dec 03, 2008 7:40 am
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Postby selden » Thu Mar 05, 2009 10:02 am

Only Chris Laurel can answer your questions for sure.

I believe that Celestia only calls the Scripted functions when they will make a difference in what is visible on the screen. You can see an SSC object as a glowing point long before you can see that it's rotating, so ScriptedOrbit functions will be called more often.

Also, If you've specified a period in your ScriptedOrbit, you might try eliminating it.. Celestia may be cacheing some of the orbital values and not calling the Scripted function for the same simulated date or when it believes that the object should be in the same position in its orbit..I think that Celestia usually assumes that an object's position will always be the same at the same date. I'm less certain about subsequent orbits.

ScriptedOrbit and ScriptedRotation functions can share variables, so, if you aren't already, you might set the appropriate values for both when either is called,

I hope this helps a little.
Selden
User avatar
selden
 
Posts: 9902
Joined: Tue Sep 03, 2002 7:21 pm
Location: NY, USA

Re: how to do Simulation and realtime visualization

Postby chris » Thu Mar 05, 2009 12:19 pm

Stuffer wrote:Hi,

My ScriptedOrbit and ScriptedRotation works. But is it possible though that Celestia calls those two functions with a different frequency?
I inserted a counter into both functions and subjectively said I would think that the ScriptedOrbit Counter counts faster than the ScriptedRotation's one.


It's possible that they are called at different frequencies. And object's ScriptedOrbit/ScriptedRotation are called whenever Celestia needs a position/orientation for that object, and there are no guarantees about when this might occur. Celestia does cache the position/orientation by a ScriptedOrbit/ScriptedRotation--it assumes that if the simulation time hasn't changed, then the result of the calculate will not change (an option to override this behavior will be implemented soon.)

Is this because of the more functions included into ScriptedRotation?
I observed that the Rotation's counter only starts when going to the s/c by the goto-command.
Can I somehow synchronise them when using both?


ScriptedRotation and ScriptedOrbit functions should be written so that they don't assume a particular calling frequency. Would it be possible to provide some of the code from your ScriptedRotation? (Feel free to PM me if you don't want to post it in the forum.)

Also when I read data from a socket and then use the written variables (defined as table in hookscript) in those functions (just assign them to locals end give those back by return), after some time celestia starts to call those functions less often, so my s/c starts "jumping" from one angle to the next. This is especially with ScriptedRotation active.


This is strange behavior... Again, I'd probably need to see some code in order to help you figure out what's going on.

Does this have something to do with my RAM? Does Celestia write something into it and it eventually gets full?
I observed that the CPU usage is on 100% even when running Celestia without doing the socket thing. Is my CPU too slow?
I have a 3.4GHz machine here with 1GB RAM and WinXP.
My graphique card is a nVidia Quadro with 128MB.


Your graphics card, CPU, and RAM are probably all just fine. Celestia can spend 100% of CPU time rendering for very complex scenes (or even not so complex--it depends a lot on your CPU and graphics card.)

--Chris
User avatar
chris
Site Admin
 
Posts: 4218
Joined: Mon Jan 28, 2002 12:21 pm
Location: Seattle, Washington, USA

Simulation/realtime vis...celestia crash with settime()

Postby Stuffer » Wed Mar 11, 2009 1:48 am

Hi,

I have a question concerning the actual time-functions of celestia.

When simulating a s/c I'm usually not simulating at current time so I have to tell Celestia the time of the simulation.
Now I know that there's the function settime(number:time) which sets the (displayed) time in celestia.
And when I use this function in a celx-script the timesetting works fine.

But when I do the call to this function in a hook script Celestia crashes regularly. So is there a special point of celestia's running time when I can at first do this call?
Or can I / do I have to access the start.cel-file from within a hook script and change the starting time in there when running celestia?

Since the starting time of the simulation is likely to change several times it's not really sufficient to manually change the starting script before running Celestia. Though it would do if there's no other opportunity.

Thanks
Stuffer
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB
User avatar
Stuffer
 
Posts: 67
Joined: Wed Dec 03, 2008 7:40 am
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Postby Vincent » Wed Mar 11, 2009 3:23 am

Stuffer wrote:Now I know that there's the function settime(number:time) which sets the (displayed) time in celestia.
And when I use this function in a celx-script the timesetting works fine.

But when I do the call to this function in a hook script Celestia crashes regularly. So is there a special point of celestia's running time when I can at first do this call?

Stuffer,

I've been using the settime function in the Lua Tools which are based on the Lua Hooks process.
It works great, and I've never had the kind of issue you've reported. Could you post the piece of
code that is causing the crash ?
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
User avatar
Vincent
 
Posts: 1356
Joined: Fri Jan 07, 2005 1:29 pm
Location: Nancy, France

Re: how to do Simulation and realtime visualization

Postby Stuffer » Wed Mar 11, 2009 4:18 am

Vincent,

thanks a lot for mentioning that it should work.
Now I figured out that my mistake was somewhere else.
I assume that it was never an actual crash but something like a timeout because the hookscript was stuck and that's why Celestia didn't do any further things.

Thanks
Stuffer
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB
User avatar
Stuffer
 
Posts: 67
Joined: Wed Dec 03, 2008 7:40 am
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Postby Vincent » Wed Mar 11, 2009 4:29 am

Stuffer wrote:thanks a lot for mentioning that it should work.

Stuffer, you're welcome. Glad you've figured this out.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3
User avatar
Vincent
 
Posts: 1356
Joined: Fri Jan 07, 2005 1:29 pm
Location: Nancy, France

Re: how to do Simulation and realtime visualization

Postby Stuffer » Tue May 19, 2009 6:57 am

I'm glad so.

Me too.

My application is working properly :).

Thanks to all helping hands in here!

--Stuffer
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB
User avatar
Stuffer
 
Posts: 67
Joined: Wed Dec 03, 2008 7:40 am
Location: Stuttgart, Germany

Previous

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest