Orbiter trajectories into Celestia

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
318
Reaction score
232
Points
58
Location
Paris Area
Hello !

Is there anybody ready to write an "Export Function" for Orbiter trajectories to Celestia (for instance)? It doesn't seem that the topic exists yet, so I am creating the topic here (also on Celestia forum) and I provide below the step-by-step procedure that I tested first. But I don't know how to program it in C+ or Lua language (and what should be the best language?).

Maybe there are other better settings in the Recorder to make this procedure easier! Indeed have you ever wanted to see your Orbiter trajectory from a distant point of view and to play it (forward and backward) in Celestia? Then "just" record and export it from Orbiter! But actually it's not so simple. Tell me your interests, your needs for explanations or your advises!

... procedure to follow...
 
Orbiter trajectories into Celestia (procedure)

Here is the step-by-step "Export" procedure that I tested. It is still a bit complicated manually (!!), and can surely be simplified and improved (maybe thanks to other Orbiter Recorder settings) :


  1. Create your own trajectory in Orbiter with the "Recorder" (Ctrl-F5), say a trip from Earth to Mars
  2. Your trajectory is stored in a ".pos" file in [Orbiter]/Flights folder, see format in [Orbiter]/Doc/Technotes/RecorderRef.pdf
  3. One block of lines is created for each of the bodies (Earth, Sun, Mars) that successively becomes the biggest contributor in the gravity vector within your trajectory.
    • The block headlines indicates STARTMJD for the starting time and the coordinate system (here "Polar", I did not see any cartesian case).
    • After the headlines, the lines provide T(sec.after STARTMJD), R(m), Phi(rad), Theta(rad) and their d/dt values. The reference is the BodyFixed reference frame (rotating Earth, then Sun J2000 ecliptic and then rotating Mars)
  4. Transform each block in lines with cartesian XYZ (+vx, vy, vz) still in the BodyFixed reference frame (I validated with a spreadsheet...wow! but it works).
    • Attention: there is a mistake here in Dr.Martin Schweiger's Recorder Doc.: use x= R.cos(Theta).cos(Phi) ; y= R.cos(Theta).sin(Phi) ; z= R.sin(Theta) (Phi is Longitude, Theta is Latitude, Z=South-to-North, [Z,X]= Null-Longitude, Y=Z^X)
    • also convert XYZ in km and copy/paste in 3 different .txt files (one per block)
    • convert Orbiter time T in Julian date : newT= T+ 2'400'000.5 + STARTMJD
  5. Rename ".txt" in ".xyz" and store in [Celestia]/extra/[yourTrip]/Data. Be careful again: decimal must be indicated with a dot "." and not a coma "," (French-writing systems!). Eventually replace all comas with dots in the files
  6. In [Celestia]/extra/[yourTrip] write the ".ssc" file: create 3 objects (1 per block) and call the .xyz with the command "sampledTrajectory {...}". Attention : specify the BodyFixed reference frame (except for Sun that is a star)

Finally you get the trajectory in Celestia... actually 3 separate trajectories because Orbiter records in the most gravity-significant reference (other settings possible?). A final step would be to merge the 3 trajectories in only one, but it requires to take into account the rotating reference of each body in the global Solar reference: another challenge! (I'm working on it)

---------- Post added at 01:33 ---------- Previous post was at 01:31 ----------

One already exists:
Link to O-H

Thank you for pointing it. I will test it!
 
I've used that convertor and the problem I had with it was it put the postition of the probe into Celestia but not the velocity or direction so I had this probe sitting there, in Earth orbit going nowhere. It was a little odd!
 
Orb2Cel MFD review

Here is the link again: Orb2Cel by brianj

This tool is a very good idea and it is really easy to use. However it should be improved for the Time Management, otherwise the most interesting parts in the trajectories may be lost. Here are the results of my tests:

The biggest problem is the Time Interval Management:

  1. Here is a real concern, let's say a "bug": if you record at 1 sample per day (because of a 6 month Earth-Mars journey), you will want decrease time rate and record the effect of the next correction burst. You would then enter a new Time interval, say 1/mn. But the change does not take effect immediately and the next recorded sample will only occur after 1 day (your previous time interval setting)!!!!
  2. A user-oriented interface should be imagined to set the Time interval: the time is requested in "days" unit, then you have to set 0.00012 "day" to record at 1 sample / sec, 0.0007 for 1/mn, 0.042 for 1/hour... too bad ;)
  3. Suggestion : Both problems could be solved with an automated time interval. You set a precision rate (x% change) and a sample is recorded each time one of the values has changed over x%

A last point (also mentioned by garyw above): Orbiter's basic Recorder *does* store the velocities but this Orb2Cel MFD tool does not! It's too bad because Celestia uses .xyz as well as .xyzv trajectories and the latter are better computed. Maybe in a coming version?

Finally it seems there is still another problem in the accuracy of the trajectories themselves. But it may come from Orbiter itself and not from the Add-on. I will investigate...
 
Hello :-)

The biggest problem is the Time Interval Management:

Here is a real concern, let's say a "bug": if you record at 1 sample per day (because of a 6 month Earth-Mars journey), you will want decrease time rate and record the effect of the next correction burst. You would then enter a new Time interval, say 1/mn. But the change does not take effect immediately and the next recorded sample will only occur after 1 day (your previous time interval setting)!!!!
That could be fixed quite easily, I think. I'll take a look.

A user-oriented interface should be imagined to set the Time interval: the time is requested in "days" unit, then you have to set 0.00012 "day" to record at 1 sample / sec, 0.0007 for 1/mn, 0.042 for 1/hour... too bad ;)
What units would you like? ;) I guess seconds would be in line with other MFD's. So if you want one sample per day, you'd have to enter 86400 ....

Suggestion : Both problems could be solved with an automated time interval. You set a precision rate (x% change) and a sample is recorded each time one of the values has changed over x%
Sorry, I don't follow: x% change of what?
I think I'll leave it to the user to specify the time interval anyway.


A last point (also mentioned by garyw above): Orbiter's basic Recorder *does* store the velocities but this Orb2Cel MFD tool does not! It's too bad because Celestia uses .xyz as well as .xyzv trajectories and the latter are better computed. Maybe in a coming version?
I made the MFD before the latest version of Celestia was released, .xyzv files weren't implemented. But can be added quite easily. Maybe .a attitude files also - but I'm not so good at quaternions!

Finally it seems there is still another problem in the accuracy of the trajectories themselves. But it may come from Orbiter itself and not from the Add-on. I will investigate...
I don't know if the Orbiter planet modules use the same data as Celestia. I can tell you that my own (very rough) test using the position of Moon relative to Earth as given by JPL Horizons, gave a discrepancy of ~4km in Orbiter and ~60km in Celestia.

I'll try and get around to updating the MFD soon :-)
Or if anyone wants the VC++ code, just ask.

Cheers,
Brian
 
It's nice to talk with the add-on's creator, hello Brian!:tiphat:

I made the MFD before the latest version of Celestia was released, .xyzv files weren't implemented. But can be added quite easily. Maybe .a attitude files also - but I'm not so good at quaternions!

I can provide you with the equations (but please verify!)

What units would you like? ;) I guess seconds would be in line with other MFD's. So if you want one sample per day, you'd have to enter 86400 ....
[...]
Sorry, I don't follow: x% change of what?
I think I'll leave it to the user to specify the time interval anyway.

Finally I've got a better idea: your MFD presents 8 buttons free. Just use some of them to change the Time Interval with a simple clic: 1/sec, 1/mn, 1/hr, 1/day, x2, x0.5 should take 6 buttons in addition of the "INT" button for customized interval.
 
Last edited:
Hi :-)
I can provide you with the equations (but please verify!)
My friend flyingcoffin sent me the euler-angles -> quaternions equations, but I'm not sure if I still have it, so: Yes! If you can send me the equations, that will be a help.

Although the fact that Orbiter has different coordinate axes to Celestia (Orbiter XYZ = Celestia XZY) makes me wonder just how easy it will be to make the conversion. I can only try and see how far my maths ability will get me :-D


Finally I've got a better idea: your MFD presents 8 buttons free. Just use some of them to change the Time Interval with a simple clic: 1/sec, 1/mn, 1/hr, 1/day, x2, x0.5 should take 6 buttons in addition of the "INT" button for customized interval.
Ah, I see! Some "presets" or "shortcuts" to set the time interval.
Maybe a good idea , I will think about it.

All the best,
Brian
 
Brian, ok, please see your PMs.
I'll post here the equations after initial checking, for everybody to check
 
Brian, ok, please see your PMs.
I'll post here the equations after initial checking, for everybody to check
Nothing in my PM Inbox. Did you send a PM?
EDIT: OK, that's weird I just checked my PM's again and I have your message! I'll get back to you asap :-)

Anyhow, here's a new version of Orb2CelMFD,if anyone wants to try it, download here:
http://myweb.tiscali.co.uk/briansutilitysite/orb2cel_v3.zip
(no documentation is included yet)

Changes:
output is now an .xyzv file (includes velocity)
sample interval units are Seconds
sample interval changes are implemented immediately
.xyzv file name includes reference object e.g. Atlantis_Earth_55635.xyzv

Haven't checked the result in Celestia yet :shifty: but the numbers in the file look OK.

I'll try to add the capability to record attitude (quaternions in Celestia .q format) soon. Hope I can get my head around those quaternions.

Cheers,
Brian
 
Last edited:
Orb2Cel v.3

Well, I tested the Orb2Cel v.3. Regarding the user-interface:

  • now the interface is much more user-friendly with unit in seconds and immediate effect of an interval change
  • I still think that some additional buttons on the right side should offer preselected intervals (1 sec, 1mn, 1hr, 1day, x2, x0.5)
  • I wonder (not tested) how the .xyzv files behave in case we change the Ref several times : say Ref=Sun then Earth then Sun again, is the "Sun" file cleared or continued?
Regarding the accuracy, there is a big concern: I recorded the full Lunar transfer scenario in the same Ref=Sun. In Celestia it does not match at all. Here is my .ssc definition:

"myGlider" "Sol"
{
...
Beginning 2453772.5969678
Ending 2453776.7414275
SampledTrajectory { Source "GL-01_sun_53772.xyzv" }
...
}

The trajectory goes from Earth orbit to an orthogonal direction ?! I know there is some troubles with ephemerides between Celestia and Orbiter but here it is something else (axis orientation?) ...have to check the equations...
 
Last edited:
Hi Boxx, thanks for testing :-)
I still think that some additional buttons on the right side should offer preselected intervals (1 sec, 1mn, 1hr, 1day, x2, x0.5)
I appreciate the suggestion, but I like to keep things as simple as possible.
I think the user should be able to figure out how many seconds in a minute/hour/day/ etc. ;)


I wonder (not tested) how the .xyzv files behave in case we change the Ref several times : say Ref=Sun then Earth then Sun again, is the "Sun" file cleared or continued?

If the reference is changed, a new .xyzv file is started (the file name is tagged with the reference). Also, if the vessel is changed, a new .xyzv file is started.

If there is already a file with the same vessel name and reference and MJD date(eg.53772), the data is added to the file.


Regarding the accuracy, there is a big concern: I recorded the full Lunar transfer scenario in the same Ref=Sun. In Celestia it does not match at all. Here is my .ssc definition:

"myGlider" "Sol"
{
...
Beginning 2453772.5969678
Ending 2453776.7414275
SampledTrajectory { Source "GL-01_sun_53772.xyzv" }
...
}

Don't forget, Orb2CelMFD always uses the Ecliptic frame of reference, so you must use the OrbitFrame {} parameter in your .ssc like this:

"myGlider" "Sol"
{
...
Beginning 2453772.5969678
Ending 2453776.7414275
OrbitFrame { EclipticJ2000 { Center "Sol" } }
SampledTrajectory { Source "GL-01_sun_53772.xyzv" }
...
}

Also, for an Earth->Moon transfer, you should use the Earth or Moon as the reference - otherwise any discrepancy between the position of Orbiter Earth and Celestia Earth will be included.

I've only tested recording a DG in Geosynchronous orbit (ref=Earth), but it seems OK. I'll try a lunar transfer and see what happens :-)

I think I've got the attitude quaternions (.q file) done - but I need to test some more.

All the best,
Brian
 
Last edited:
Hi,
hope everyone had a good Christmas :-)

Here's a new version of Orb2CelMFD, if anyone wants to test it before I put it on OH:

http://myweb.tiscali.co.uk/briansutilitysite/orb2celmfd_v4.zip

Changes:
Records attitude .q file
Can use Solar System Barycentre as reference object
Data point interval can be time(seconds) or number of steps

BTW, I've found Celestia really doesn't like .xyzv files with a non-constant interval between data points - Celestia's interpolation between data points makes the spacecraft seem to "jump about". Using Orbiter's "Fixed Time Steps" option can cure this ;-)

Best wishes to all for the New Year.

Cheers,
Brian
 
Just gave this a go but couldn't get Celestia to add the object.

I think it's to do with the SSC file which I've created by hand as the MFD doesn't do this. What am I supposed to put for the Beginning and Ending elements in the SSC file?

Cheers.
 
What am I supposed to put for the Beginning and Ending elements in the SSC file?
Hi Gary,
the Beginning and Ending elements in the .ssc are the dates between which your object(spacecraft) will exist in celestia. I generally use the first and last julian date entry from the .xyzv file.

The Celestia Wikibook is pretty useful for understanding how .ssc files work:
http://en.wikibooks.org/wiki/Celestia#Customizing_Celestia

Cheers,
Brian
 
Back
Top