[Solved] how to do Simulation and realtime visualization

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

[Solved] how to do Simulation and realtime visualization

Post #1by Stuffer » 29.12.2008, 11:27

hey guys

I'm working on a project where a satellite is simulated and at the same time is supposed to be displayed on another screen by celestia.
At the moment I'm not sure where to start.

I'll try to detail the problem. The simulator is running on one machine and I'll try to get the values like orientation or position out of that into a text file. From there I would like Celestia to get the values and if necessary change position or orientation in realtime. The satellite is supposed to be shown on another machine.
My actual problem at the moment is how can I make Celestia read the the values and use them for the time the simulation is running?

Moving my satellite would probably be possible by a trajectory file, is that right? But that file would be fixed when celestia starts. What I need is to give Celestia the "movement-commands" while it is running.

Can I do so by scripts or something like that? Can I give those values to Celestia from a c++-program?

I hope my problem got clear.
Thanks in advance
Last edited by Stuffer on 17.07.2009, 11:28, edited 1 time in total.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #2by selden » 29.12.2008, 15:01

You can use ScriptedOrbit and ScriptedRotation.
They specify Lua functions which calculate the object's position and orientation.
Lua can do file I/O.

See the Celestia WikiBook for details:
http://en.wikibooks.org/wiki/Celestia/T ... iptedOrbit
and
http://en.wikibooks.org/wiki/Celestia/R ... edRotation
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #3by Stuffer » 13.01.2009, 14:59

thank you Selden.

I'm trying to use ScriptedOrbit but I still don't get where Celestia could get new values from.

The ScriptedOrbit {...} is put into the SSC-File with all starting values (Periods, Amplitudes, etc...) and from there calls a module with an orbit function. That's what I got from the wiki.

But how do I make Celestia call this function again while running?
Can a hook script read the SSC-file more often?
Should I implement a hook script which directly calls the Orbit function several times?
But then, how is the Orbit function related to my satellite?
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #4by selden » 13.01.2009, 15:07

The Scripted functions are called again every time Celestia's window refreshes while the object is in the field of view, and are provided with the current simulated date.

The Lua manual documents the I/O functions.
http://www.lua.org/docs.html
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #5by Stuffer » 15.01.2009, 13:25

When I put some variables in the ssc-file as they are in the example given in the wiki, are those values the starting ones?
Which units are they given in?

Code: Select all

ScriptedOrbit
    {
        Module "orbits"
        Function "lissajous"

        PeriodX 1
        PeriodY 3.1
        PeriodZ 2.4
        PhaseX 0.5
        PhaseY 0.2
        PhaseZ 0.0
        AmplitudeX 1000
        AmplitudeY 800
        AmplitudeZ 540
    }



So I should pass new values to the lissajous function while running celestia, otherwise the function will calculate with the starting values over and over again?
Is this why I need a lua hook script? Or where do I get those values from? Does the hook script read the values from a text file and is able to pass them over to the lissajous function?

Do I still have to define the EllipticalOrbit-Part?
Example:

Code: Select all


EllipticalOrbit
   {
   Epoch  2453445.28885625
   Period  0.06569905
       SemiMajorAxis  6877.661
       Eccentricity  0 #0.0008874
       Inclination  0 #97.4274
       AscendingNode  0 #324.0722
       ArgOfPericenter  0 #124.2127
      MeanAnomaly  0 #235.9981
     }


I tried to implement one lua hook script which should focus on my spacecraft from the beginning, but then celestia didn't start running. I read something in the wiki about giving the control back to celestia when using scripts. Is there a function or a call that necessarily has to be included into the script?

Does Celestia's window automatically refresh or do I have to do that manually?
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #6by selden » 15.01.2009, 14:57

You need to examine the code of the Lissajous function to see how the variables are used.

Except for Module (which specifies the name of the file to be loaded) and Function (which specifies the name of the subroutine to be called), the variable names and their units are optional. Their names and uses are determined by the code in the Lua Scripted function that you provide. If the variable names specified in the SSC file are not referenced in the Lua Function that you provide, they are simply ignored.

How they are used is also determined by the code in that Lua function: their values can be used every time it's called, or they could be initialization values which are used only the first time it's called, or they could be ignored entirely.

In general, it is expected that they provide parameters for a trajectory and that they are modified by the simulated date when the Scripted function is called.

e.g orbitX = X0 + Vx*time + 0.5 Ax*time**2
where oribitX is the X value returned by the ScriptedOrbit function to Celestia, while
X0, Vx and Ax might be values specified in the SSC file, or determined by some realtime function. (Note that this example is strictly pedagogical and does not correspond to usage by any particular function.)

A Hook script is not needed in order to use ScriptedOrbit and ScriptedRotation functions: it's primarily used to load user interface functions which are used to control the user's viewpoint, not to control the trajectories and orientations of SSC objects, although it could. When using a Module containing Scripted functions, a Hook script can be completely irrelevant, depending on the design of your software.

For example, my Hale Telescope Addon does not use a Hook function to implement its user interface and telescope control functions.

ScriptedOrbit overrides EllipticalOrbit. If both are specified, the EllipticalOrbit is ignored.

I hope this helps a little.
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #7by Stuffer » 19.01.2009, 10:56

Thanks for your help
I still have a problem with the ScriptedOrbit when I want to read orbit data from a file.
Perhaps you can help me here:

The part of my ssc where I tell Celestia to use ScriptedOrbit with the file orbits2.lua

Code: Select all


ScriptedOrbit
   {
   Module "orbits2"
   Function "lissajous"

   Inclination 97.4274
   PeriodX 0.06569905 #1
   PeriodY 0.06569905 #3.1
   PeriodZ 0.06569905 #2.4
   PhaseX 0 #0.5
   PhaseY 0 #0.2
   PhaseZ 0 #0.0
   AmplitudeX 889
   AmplitudeY 6877.661
   AmplitudeZ 6820
     }

The specifications are there because sometimes I use another Module (orbits.lua from the wiki), with which it works really fine, but for my orbits2.lua they do not matter as you will see by the following:

Here's my orbits2.lua

Code: Select all

function lissajous(t)
   -- Create a new table
   local orbit = {};

   -- Save the parameter list
   -- orbit.params = t;

   -- Set the required fields boundingRadius and position; note that position is actually a function

   -- Compute the bounding radius from the amplitudes
   orbit.boundingRadius = 6877.661

   --[[       math.sqrt(t.AmplitudeX * t.AmplitudeX +
                 t.AmplitudeY * t.AmplitudeY +
                 t.AmplitudeZ * t.AmplitudeZ)
]]

   orbitFile = io.open("OrbitdatenFlyingLaptop.txt", "r") --> one Orbit is defined in one line: ideg   irad   X0   Y0   Z0   Period

   --get Inclination of Orbit
   orbit["ideg"] = orbitFile:read("*n") --> Degrees
   orbit["irad"] = orbitFile:read("*n") --> Radian


   -- get Amplitudes of Orbit
   orbit["X0"] = orbitFile:read("*n")
   orbit["Y0"] = orbitFile:read("*n")
   orbit["Z0"] = orbitFile:read("*n")

   --get Period of Orbit
   orbit["Period"] = orbitFile:read("*n")
   orbitFile:read("*l")


   -- The position function will be called whenever Celestia needs the position of the object
   function orbit:position(tjd)
       local t = tjd - 2454625.13889
       local pi2 = math.pi * 2;
       local x = orbit.X0 * math.cos((t / orbit.Period) * pi2)
       local y = orbit.Y0 * math.sin((t / orbit.Period) * pi2)
       local z = orbit.Z0 * math.cos((t / orbit.Period) * pi2)

      return x, y, z
    end


   --[[ The position function will be called whenever Celestia needs the position of the object
   function orbit:position(tjd)
       local t = tjd - 2454625.13889
       local pi2 = math.pi * 2;
       local x = orbit.params.AmplitudeX * math.cos((t / orbit.params.PeriodX + orbit.params.PhaseX) * pi2)
       local y = orbit.params.AmplitudeY * math.sin((t / orbit.params.PeriodY + orbit.params.PhaseY) * pi2)
       local z = orbit.params.AmplitudeZ * math.cos((t / orbit.params.PeriodZ + orbit.params.PhaseZ) * pi2)



   --local x = orbit.boundingRadius * math.cos((t / orbit.params.PeriodX + orbit.params.PhaseX) * pi2) * math.sin(orbit.params.Inclination / 360 * pi2)
   --local y = orbit.boundingRadius * math.sin((t / orbit.params.PeriodY + orbit.params.PhaseY) * pi2)
   --local z = orbit.boundingRadius * math.cos((t / orbit.params.PeriodZ + orbit.params.PhaseZ) * pi2) * math.cos(orbit.params.Inclination / 360 * pi2)
       
      return x, y, z
    end ]]



    return orbit
end

As you will realize I tried to get there from the original lissajous function from the wiki.

And here's how the "OrbitdatenFlyingLaptop.txt"-file looks like:

Code: Select all

45   0.7853975           4863.237506    6877.661   4863.243958   0.06569905
0   0              0              6877.661   6877.661           0.06569905
1   0.017453278   120.0316337   6877.661   6876.613501   0.06569905
2   0.034906556   240.0267047   6877.661   6873.471322   0.06569905
3   0.052359833   359.9486614   6877.661   6868.235421   0.06569905
4   0.069813111   479.7609744   6877.661   6860.907392   0.06569905
5   0.087266389   599.4271478   6877.661   6851.489468   0.06569905
6   0.104719667   718.9107302   6877.661   6839.984517   0.06569905
7   0.122172944   838.1753258   6877.661   6826.396044   0.06569905
8   0.139626222   957.1846055   6877.661   6810.728189   0.06569905
9   0.1570795           1075.902318   6877.661   6792.985723   0.06569905
...

I just wanted to test with it so I used a span of angles from 0 to 90 degrees inclination.
45 is on top to actually see changes.

Can you see why my orbits2.lua module doesn't work?
Do I have to tell Celestia to refresh the viewing window (in order to call the orbit:position function again and again)? Or is this done like usual renderings by 25 frames per second?
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #8by selden » 19.01.2009, 12:42

Please attach a zip file containing the entire Addon, with a functional ssc.
I'd rather not spend my time trying to create one.
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #9by Stuffer » 19.01.2009, 13:49

Here's my complete Add-on Selden.
Thanks for having a look at it.
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #10by selden » 19.01.2009, 18:04

There are several issues.

1. First, if possible, you should try out new code in a CELX script before using it in a Scripted function. That way you can edit it and try again without having to restart Celestia.

2. While developing ScriptedOrbit and ScriptedRotation routines, *always* include typout so that you know the function is active. Comment it out when the typeout is not needed any more. E.g. insert the two lines
local s = " x = "..x..", y = "..y..", z = "..z
celestia:flash(s)
immediately before the return statement which provides the xyz coordinates.
If you see the typeout, the function is doing something.
If you see no typeut, Lua has decided the function is invalid.

Debugging Lua code under Celestia can be extremely frustrating. Some errors cause Celestia to crash, some are reported in popups, some errors are reported in Celestia's "console log" (type a tilde to see it) and some errors are not reported at all.

This last is the case with your Scripted function: io.open is failing.
Your code needs to check its status codes and do something appropriate.

Also, don't forget to include requestsystemaccess() in CELX scripts which do I/O.
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #11by Stuffer » 20.01.2009, 14:38

Thank you Selden, I really appreciate your help.

Those issues helped me a lot, but I'm still not able to make Celestia open my file.
I tried it as celx-Script and it worked perfectly. I also downloaded a lua interpreter called SciTE and there it also works when I call the lissajous function from within the .lua-file.

I tried to work with outputs and then I realized what you mentioned before. Celestia jumps out of my function when trying to open the file.
But even if I try to check sth. like:

Code: Select all

celestia:flash("Here we are!",10)
orbitFile = assert(io.open("C:/Programme/Celestia/extras/Flying Laptop/OrbitdataFlyingLaptop.txt", "r")) --> one Orbit is defined in one line: ideg   irad   X0   Y0   Z0   Period

   if (orbitFile == nil) then
      celestia:flash("Error while trying to open file")
   else
      celestia:flash("orbitFile is not equal to nil")
   end
celestia:flash("Are we here?")

the last output I get is "Here we are!"

I tried both the whole path to the file and just the filename. Both didn't work.
Is there a special folder where I would have to put the file? Or does Celestia need another file format, such as .dat? I tried .dat and put it into celestia/data but that didn't work either. Is there a method to even see if Celestia finds the file? Since
Can you see where I'm wrong?
Win XP Pro x Core2Duo 2,1GHz x 2 GB RAM x NVidia Quadro FX 1500 256 MB

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

Re: how to do Simulation and realtime visualization

Post #12by selden » 20.01.2009, 23:28

I managed to do I/O from a Scripted function by doing the following:

1. in celestia.cfg,edit the line which defines ScriptSystemAccessPolicy to be
ScriptSystemAccessPolicy "allow"

2. in the ScriptedOrbit function, make sure io.open is called only once.
(I added a counter in the position function and called io.open when it
reached a specific value.)

3. test for io.open returning a valid file handle

4. explicitly reference the file handle when using the read function
You cannot depend on the default file handle being preserved between calls to the Scripted function. In other words, the variable containing the file handle has to be a global.

Here's the scripted function that I used to test the functionality. It's rather crude but hopefully understandable. It does output to the screen instead of generating new xyz values.

Code: Select all

-- ScriptedOrbit function my_io to demo io.open and io.input():read

-- waits until ncall gets to certain values to do i/o
ncall = 0

-- preliminary messages
msg1 = "counting..."
msg2 = "...io.open not called"
line = " [ ] "

function my_io(t)
   -- Create a new table
   local orbit = {};

   -- Save the parameter list
   orbit.params = t;

   -- Set the required fields boundingRadius and position; note that position is actually a function

   -- Compute the bounding radius from the amplitudes
   orbit.boundingRadius = 1


   -- The position function will be called whenever Celestia needs the position of the object

   function orbit:position(tjd)

-- open file after waiting for some time
-- this is to guarantee a delay before the first on-screen message
-- and to ensure io.open is called only once
-- other techniques could be used for production code

   ncall = ncall +1

-- open file at 100th call

      if (ncall == 100)
       then

   msg1 = "calling io.open..."

-- construct file specification from directory containing this ScriptedOrbit

-- obtain information about this lua module
   local sourceinfo = debug.getinfo(1,"S")
   local sourcefile = sourceinfo.source

-- find terminal \ or / and strip this module's trailing filename
     local n_1,n_2 = string.find(sourcefile,".*%\\")
       if (n_1 == nil) then n_1,n_2 =string.find(sourcefile,".*%/") end

-- ignore leading @ seen when called from a celxx script
-- assume in celxx subdir: remove trailing dir name, too.
-- i.e. to specify a valid filename, set the final argument of string.sub to
-- n_2-6

      local sourcedir = string.sub(sourcefile,n_1+1,n_2-6)

-- specify file name
      local partialpath = sourcedir.."file.txt"
-- specify path to Celestia as prefix to file spec.
-- you will need to change this to match your system's configuration
      local celpath = "C:/Program Files/Celestia/"
-- generate file spec of input file
      local filepath = celpath..partialpath

-- attempt to open file
   orbitFile,msg2 = io.open(filepath, "r")

   msg1 = "returned from io.open..."

        if (msg2 == nil)
      then
        if (orbitFile == nil)
          then
                 line = " io.open returned nil"
      end
        msg2 = "...empty msg2"
           end
   end

-- read first line from file at 200th call

      if (ncall == 200)
       then
   line = io.input(orbitFile):read()
   if (line == nil)
     then
      line = " io.read returned nil"
     end
   end

 -- read second line from file at 200th call
     if (ncall == 300)
       then
   line = io.input(orbitFile):read()
   if (line == nil)
     then
      line = " io.read returned nil"
-- maybe should close the file, too.
     end
   end


-- display frame count and status of i/o open
   s = msg1..ncall..msg2.." line: "..line
   celestia:flash(s)

-- this routine is only for testing i/o operations, so
-- always return constant position regardless of file i/o
   local x = 1
   local y = 1
   local z = 1

       return x, y, z
    end

    return orbit
end
Selden

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 23 years
Location: Seattle, Washington, USA

Re: how to do Simulation and realtime visualization

Post #13by chris » 21.01.2009, 00:55

selden wrote:4. explicitly reference the file handle when using the read function
You cannot depend on the default file handle being preserved between calls to the Scripted function. In other words, the variable containing the file handle has to be a global.

A reference to the file handle must be kept, but that doesn't mean it has to be global. If you need to keep the file open, a better approach is to keep a reference to it in orbit object created by the script orbit function. If you open the file in the orbit:position, do this:

Code: Select all

   self.orbitFile,msg2 = io.open(filepath, "r")


Then, you're guaranteed to be able to use orbitFile in subsequent calls to orbit:position.

'self' is an implicit variable in Lua. It's the table automatically pushed onto the Lua stack for functions declared using the colon syntax. The following two definitions are equivalent:

Code: Select all

function orbit:position(t)
 ...body...
end


and

Code: Select all

orbit.position = function(self, t)
   ...body...
end


When creating a celx ScriptedOrbit, the self object is where parameters necessary for computing the position should be stored.

What you probably want to do is just open the file when the orbit object is created, load the data into memory, then close it again. This looks like the approach taken in Stuffer's example. You can do I/O inside the position function, but it requires some caution. Calls to a ScriptedOrbit's position function may happen any number of times per frame rendered (include zero times.)

--Chris

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 23 years
Location: Seattle, Washington, USA

Re: how to do Simulation and realtime visualization

Post #14by chris » 21.01.2009, 00:59

I'm going to work on a very simple file loading example ScriptedOrbit for the Celestia Wikibook. This seems like it could be a very common use for ScriptedOrbit.

--Chris

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

Re: how to do Simulation and realtime visualization

Post #15by selden » 21.01.2009, 12:57

Chris,

Thanks for the clarifications!
I suspect my lack of experience with OO programming is showing. ;)
Selden

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #16by Stuffer » 21.01.2009, 16:20

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

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

Re: how to do Simulation and realtime visualization

Post #17by selden » 21.01.2009, 16:49

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

Topic author
Stuffer
Posts: 67
Joined: 03.12.2008
With us: 16 years 1 month
Location: Stuttgart, Germany

Re: how to do Simulation and realtime visualization

Post #18by Stuffer » 05.03.2009, 16:27

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

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

Re: how to do Simulation and realtime visualization

Post #19by selden » 05.03.2009, 17:02

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

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 23 years
Location: Seattle, Washington, USA

Re: how to do Simulation and realtime visualization

Post #20by chris » 05.03.2009, 19:19

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


Return to “Scripting”