Overview
Basilisk’s gravity system is split between theGravityEffector (built into Spacecraft) and swappable GravityModel objects. The two primary models are:
- Point-mass (
GravBodyData) — simple µ/r² gravity, adequate for most mission analysis. - SphericalHarmonicsGravityModel — full J2..Jn gravity using normalized C/S coefficients.
GravBodyData
Defines a gravitating body (planet, moon, sun) attached to the spacecraft’sgravField.
SPICE body name used to look up ephemeris data (e.g.,
"earth_planet_data").Gravitational parameter µ = G·M [m³/s²].
Set
True for the primary attracting body. Only one central body is allowed.Set
True to use the attached SphericalHarmonicsGravityModel instead of a point mass.SphericalHarmonicsGravityModel
Computes the gravitational acceleration using a spherical harmonics expansion.Configuration parameters
Reference equatorial radius of the body [m].
Gravitational parameter [m³/s²].
Maximum degree of spherical harmonics to evaluate. Must not exceed the size of
cBar / sBar.Normalized C (cosine) spherical harmonics coefficients. Indexed as
cBar[n][m].Normalized S (sine) spherical harmonics coefficients. Indexed as
sBar[n][m].Key methods
Validates that
cBar and sBar are set and pre-computes internal recursion coefficients. Called automatically during Spacecraft.Reset().Returns an optional error string; empty means success.Returns the gravitational acceleration vector at the given body-fixed position [m/s²].An overload accepts
(position, degree, include_zero_degree) to truncate the expansion at a lower degree.Loading coefficients from a file
Use the helpergravCoeffOps to read standard EGM coefficient files: