test_gravity

test_gravity.loadSatelliteTrajectory(utcCalInit: str, stopTimeSeconds: float, dtSeconds: float)[source]

Loads the trajectory of a GPS satellite from SPICE kernels from the given date (utcCalInit), for stopTimeSeconds seconds, with the position reported every dtSeconds seconds.

test_gravity.test_dumbbell(showPlots, initialAngularRate)[source]

Test gravity on a compound spacecraft made up of two point masses rigidly connected but separated by 200 m:

  _____
 /     \            <----------- 200 m ----------->
| Earth |          O---------------@---------------O
 \_____/        'left'          'center'         'right'

The ‘left’ body starts closer to the Earth. The ‘right’ body has the same mass as the ‘left’ body and starts further from the Earth. The ‘left’, ‘right’, and center of the Earth are initially located in the same line. ‘center’ is a “fictitious” (zero-mass) body that we can use to represent the center of mass of the spacecraft.

If initialAngularRate is True, then the total configuration is given an angular velocity equal to 2pi over the period of the orbit, which means that the body will tend to rotate about its center once every time the spacecraft rotates about the Earth. If initialAngularRate is False, then no initial rotation rate is given

We can check two things:

  • The center of mass of this spacecraft should maintain constant orbital parameters given that this is a point-mass problem and all bodies are rigidly connected.

  • The two bodies are far apart enough for the gravity gradient to be noticeable over an orbit. The gradient will tend to keep the line connecting the two masses parallel to the line connecting the Earth to the spacecraft (keep the spacecraft pointing towards Earth).

  • If initialAngularRate is True, then the initial angular rate is such that this pointing is also maintained. Since we have both the initial rate and gravity gradient favoring this alignment, we can expect the alignment to indeed be maintained exactly through the orbit.

  • If initialAngularRate is False, then alignment will not be maintained exactly, but the gradient is strong enough that we can expect the “inner” body to always remain closer to Earth than the “outer” body, since it feels a stronger gravity pull.

test_gravity.test_gps(showPlots: bool, useSphericalHarmonics: bool, useThirdBodies: bool)[source]

Compares the trajectory produced by Basilisk with the true trajectory of a GPS satellite, as obtained from SPICE kernels.

The useSphericalHarmonics and useThirdBodies entries can be used to tune the accuracy of the gravity model, and thus how close should the Basilisk result be to the SPICE data.

The satellite state is initialized from SPICE, then propagated with Basilisk for 1 hour. The final state is expected to match the SPICE state at the time by:

  • < 300 m if point mass gravity is used.

  • < 30 m if spherical harmonics is used by no third-body effects.

  • < 30 m if spherical harmonics and third-body effects are considered.

Note that the inclusion of third body effects seems to have no effect on the accuracy. Something that should be investigated further.

test_gravity.test_mujocoVsSpacecraft(showPlots: bool, useSpice: bool, useSphericalHarmonics: bool, useThirdBodies: bool)[source]

Tests that the same scenario (simple LEO orbit with only gravity) produces the same results when running with a spacecraft.Spacecraft dynamical object and a mujoco.MJScene.

If showPlots is True, the scenario is run for 24 hr and the differences are shown in plots. If it’s False, then the scenario is only run for 10 seconds and an assertion is raised if the results disagree on a very tight tolerances.

test_gravity.test_pointMass(showPlots)[source]

Test that the gravity model with point-mass gravity conserves the initial orbital elements after two orbits.