API Question Get name/mass of a CELBODY (and what if it is NULL?)

Kolodez

New member
Joined
Jun 18, 2018
Messages
21
Reaction score
0
Points
1
I want to get ephemeris data of all bodies. So I do the following:

C++:
unsigned int nGBodies = oapiGetGbodyCount();
for (unsigned int iGBody = 0; iGBody < nGBodies; iGBody++) {
    OBJHANDLE hGBody = oapiGetGbodyByIndex (iGBody);
    CELBODY *pGBody = oapiGetCelbodyInterface (hGBody);
    ...
}

What to do when pGBody == NULL? The reference says that the oapiGetCelbodyInterface() function returns: "Pointer to the CELBODY class instance for the body, or NULL if the body is not controlled by an external module." What does that mean and how can I get ephemeris data for those bodies?

And how to get the names and the masses of bodies? Coded as above, I know only the index and can sometimes obtain ephemeris data, but not the name or mass. Thanks for your help!
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
36,996
Reaction score
1,677
Points
203
Location
Langendernbach
If the return value is null, the planet/satellite is only defined by a configuration file.
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
190
Reaction score
55
Points
28

n72.75

Addon Developer
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,345
Reaction score
913
Points
128
Location
Biddeford ME
Website
mwhume.space
Preferred Pronouns
he/him
To mirror what @Urwumpe said, Orbiter has a mix of bodies whos positions are defined by an ephemeris module, or are directly propagated based on some parameters in the config file.

A better question might be: what are you trying to do? Maybe there's an easier way that works for all bodies.
 

Kolodez

New member
Joined
Jun 18, 2018
Messages
21
Reaction score
0
Points
1
Hi, thank you so far. @n72.75, I would like to obtain the locations and velocities for all bodies, for different times. The names are only necessary to map them correctly.

Now I have seen that pGBody is NULL only for Vesta, the Neptune moons and one of the Uranus moons.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
36,996
Reaction score
1,677
Points
203
Location
Langendernbach
Hi, thank you so far. @n72.75, I would like to obtain the locations and velocities for all bodies, for different times. The names are only necessary to map them correctly.

Now I have seen that pGBody is NULL only for Vesta, the Neptune moons and one of the Uranus moons.

In that case the oapiGetGlobalPos/oapiGetGlobalVel functions might be better suited.
 

Kolodez

New member
Joined
Jun 18, 2018
Messages
21
Reaction score
0
Points
1
But oapiGetGlobalPos/oapiGetGlobalVel do not accept time as argument.
 

n72.75

Addon Developer
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,345
Reaction score
913
Points
128
Location
Biddeford ME
Website
mwhume.space
Preferred Pronouns
he/him
The config/propagated bodies do not work from ephemerides. Orbiter calculates their new position and velocity each timestep.

If you tell us what you're trying to do, we may be able to come up with an easier way. Some of these ephemerides are avaliable from JPL's website, if that helps.
 

Kolodez

New member
Joined
Jun 18, 2018
Messages
21
Reaction score
0
Points
1
Do you mean that the bodies without ephemeris data are calculated by Orbiter only for those times, which are necessary, as if they were vessels?
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
190
Reaction score
55
Points
28
Some of these ephemerides are avaliable from JPL's website, if that helps.
The default Orbiter configuration has different modules for different celestial bodies and they don't always precisely agree with JPL.
Maybe it's high time to finally migrate to the JPL/NAIF toolkit called SPICE and use those ephemerides in Orbiter.
I did it many years ago. My log file looks like this now:
000000.000: Module spice.dll ............. [Build 211204, API 211204]
000000.000: spice.dll: Kernel Kernels\orbiter.bsp - OK.
000000.000: spice.dll: Kernel Kernels\codes_300ast_20100725.tf - OK.
000000.000: spice.dll: Kernel Kernels\naif0012.tls - OK.
000000.000: spice.dll: Kernel Kernels\pck00010.tpc - OK.
000000.000: spice.dll: SUN (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: MERCURY (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: VENUS (MJD 36934.0 - 69807.0) - OK
000000.000: Module VenusAtm2006.dll ...... [Build 211207, API 211207]
000000.000: Module EarthAtmJ71G.dll ...... [Build 211207, API 211207]
000000.000: spice.dll: EARTH (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: MOON (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: MARS (MJD 36934.0 - 69807.0) - OK
000000.000: Module MarsAtm2006.dll ....... [Build 211207, API 211207]
000000.000: spice.dll: PHOBOS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: DEIMOS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: JUPITER (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: IO (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: EUROPA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: GANYMEDE (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: CALLISTO (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: AMALTHEA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: HIMALIA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: SATURN (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: MIMAS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: ENCELADUS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: TETHYS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: DIONE (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: RHEA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: TITAN (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: HYPERION (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: IAPETUS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: PHOEBE (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: URANUS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: MIRANDA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: ARIEL (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: UMBRIEL (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: TITANIA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: OBERON (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: NEPTUNE (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: TRITON (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: PROTEUS (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: NEREID (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: PLUTO (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: CHARON (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: NIX (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: HYDRA (MJD 36934.0 - 69807.0) - OK
000000.000: spice.dll: VESTA (MJD 36934.0 - 69807.0) - OK
000000.000: Finished initialising world

orbiter.bsp (~700Mb) is created as:
LEAPSECONDS_KERNEL = naif0012.tls
SPK_KERNEL = orbiter.bsp

BEGIN_TIME = 1960 JAN 01 00:00:00.000 TDB
END_TIME = 2050 JAN 01 00:00:00.000 TDB

SOURCE_SPK_KERNEL = de440s.bsp
INCLUDE_COMMENTS = yes
BODIES = 10, 1, 199, 2, 299, 3, 399, 301, 4, 5, 6, 7, 8, 9

SOURCE_SPK_KERNEL = mar097.bsp
INCLUDE_COMMENTS = yes
BODIES = 499, 401, 402

SOURCE_SPK_KERNEL = jup365.bsp
INCLUDE_COMMENTS = yes
BODIES = 599, 501, 502, 503, 504, 505

SOURCE_SPK_KERNEL = jup344.bsp
INCLUDE_COMMENTS = yes
BODIES = 506

SOURCE_SPK_KERNEL = sat427.bsp
INCLUDE_COMMENTS = yes
BODIES = 699, 601, 602, 603, 604, 605, 606, 607, 608, 609

SOURCE_SPK_KERNEL = ura111.bsp
INCLUDE_COMMENTS = yes
BODIES = 799, 701, 702, 703, 704, 705

SOURCE_SPK_KERNEL = nep095.bsp
INCLUDE_COMMENTS = yes
BODIES = 899, 801, 802, 808

SOURCE_SPK_KERNEL = plu058.bsp
INCLUDE_COMMENTS = yes
BODIES = 999, 901, 902, 903

SOURCE_SPK_KERNEL = codes_300ast_20100725.bsp
INCLUDE_COMMENTS = yes
BODIES = 2000004
All ehpemerides are from https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/
 
Last edited:

n72.75

Addon Developer
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,345
Reaction score
913
Points
128
Location
Biddeford ME
Website
mwhume.space
Preferred Pronouns
he/him
The default Orbiter configuration has different modules for different celestial bodies and they don't always precisely agree with JPL.
Maybe it's high time to finally migrate to the JPL/NAIF toolkit called SPICE and use those ephemerides in Orbiter.
I did it many years ago. My log file looks like this now:


orbiter.bsp (~700Mb) is created as:

All ehpemerides are from https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/
I'm very interested in how you did this. Is there an older thread where this was described, or should we start one?
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
190
Reaction score
55
Points
28
@n72.75
It's a very old topic

Orbiter has become open source but some celbody modules are missing (no x64 versions whatsoever), so switching to more precise JPL engine it's a reasonable solution.
I still use Wishbone's latest code (from spice_revisited.zip) with latest x64 version of Orbiter built from from github sources. All works fine.
 
Last edited:
Top