- current simulation rate
- number of spacecraft
- spacecraft 1 ID
- epoch for spacecraft 1 state
- position vector spacecraft 1
- velocity vector spacecraft 1
- attitude quaternion spacecraft 1
- angular velocity vector spacecraft 1
- spacecraft n ID
- epoch for spacecraft n state
- position vector spacecraft n
- velocity vector spacecraft n
- attitude quaternion spacecraft n
- angular velocity vector spacecraft n
Each time such a block of data is received:
- the actual simulation time would be compared to the one received on the socket and if they differ by more than some epsilon, the simulation time would be reset.
- the simulation rate is set
- the data (epoch and states) for each spacecraft is stored in some global variables.
The scripted orbit called with argument t would then return (position vector spacecraft at epoch)+(velocity vector spacecraft at epoch)*(t-epoch)
(we could also imagine a higher order scheme where acceleration or other extrapolation/interpolation parameters are passed via the socket)
Similarly the scripted attitude would return the quaternion at epoch rotated after dt=(t-epoch) at provided angular velocity.
This scheme requires that the lua hook and the scriptedOrbit, scriptedOrientation share some variables.
Therefore I am thinking of adding a new celx command to store variables in a dictionary and retrieve them. This dictionary implemented in C++ in celestia would then be used to share variables across all scripts.
What do you think?
Is this the right approach?
Do you have a better idea on how to do this?