scenarioBasicOrbit.py, the most minimal complete Basilisk scenario. You will set up a spacecraft, attach a gravity model, configure an orbit, run the simulation, and retrieve position and velocity data.
This scenario is the recommended starting point before exploring more advanced examples. It demonstrates only translational (orbital) motion — rotational dynamics are present but use default values and are not tracked.
What this scenario demonstrates
- Creating a
SimBaseClasssimulation container with a single dynamics process and task - Instantiating a
spacecraft.Spacecraft()module - Adding a planetary gravity body (Earth or Mars) via
simIncludeGravBody - Optionally enabling spherical harmonics for higher-fidelity gravity
- Converting classical orbital elements to inertial position and velocity vectors
- Recording spacecraft state output messages and plotting results
Key modules used
| Module | Package | Role |
|---|---|---|
spacecraft.Spacecraft | Basilisk.simulation | Integrates translational and rotational equations of motion |
gravBodyFactory | Basilisk.utilities.simIncludeGravBody | Creates and attaches planetary gravity effectors |
SimBaseClass | Basilisk.utilities.SimulationBaseClass | Top-level simulation container |
orbitalMotion | Basilisk.utilities | Converts between orbital elements and state vectors |
macros | Basilisk.utilities | Unit conversion helpers (e.g. sec2nano, D2R) |
Running the scenario
run() function accepts four parameters:
Step-by-step walkthrough
Create the simulation container and process
Every Basilisk simulation starts with a
SimBaseClass instance. You then create a named process and add a task with a fixed integration time step.Instantiate and add the spacecraft
Create a At this stage the spacecraft has no mass properties set — that is fine for a pure orbital simulation because gravity-only dynamics do not depend on mass.
Spacecraft object, assign it a tag, and register it with the task.Add a gravity body
Use For Mars, replace
gravBodyFactory to create Earth or Mars and attach it to the spacecraft.createEarth() with createMarsBarycenter() and use DataFile.LocalGravData.GGM2BData for the harmonics file.Calling
gravFactory.addBodiesTo(scObject) wires up the complete gravity effector list to the spacecraft in a single call, regardless of how many bodies are in the factory.Configure the orbit and set initial conditions
Basilisk’s The
orbitalMotion utilities let you define an orbit in classical elements and convert to inertial Cartesian vectors.GEO and GTO cases follow the same pattern with different semi-major axis and eccentricity values.Set the simulation duration and configure data recording
Compute the simulation time from the orbital period and attach a message recorder to the spacecraft state output.
Initialize and run the simulation
InitializeSimulation() calls self_init() and reset() on every module. ConfigureStopTime() followed by ExecuteSimulation() advances the simulation forward.Orbit case comparison
orbitCase | Semi-major axis | Eccentricity | Notes |
|---|---|---|---|
'LEO' | 7000 km | 0.0001 | 33.3° inclination |
'GTO' | (rLEO + rGEO) / 2 | 1 - rLEO/a | Zero inclination |
'GEO' | 42000 km | 0.00001 | Zero inclination |
Vizard visualization
To stream the simulation to the Vizard application, uncomment theenableUnityVisualization call: