scenarioFormationBasic.py, which demonstrates how to simulate multiple spacecraft in a single Basilisk process: a 3-axis attitude-controlled servicer and two tumbling debris objects.
What this scenario demonstrates
- Creating and configuring multiple
spacecraft.Spacecraft()instances in one simulation - Synchronizing the numerical integration of coupled spacecraft with
syncDynamicsIntegration - Using
hillPointto align a spacecraft with its Hill (local vertical / local horizontal) frame - Adding free-spinning reaction wheels to a debris object
- Attaching cameras and lights to spacecraft for Vizard visualization
- Connecting FSW modules for RW-based attitude control
Simulation layout
The scenario creates three spacecraft in a singlesimProcess:
- Servicer (
scObject) — attitude-controlled with 3 Honeywell HR16 RWs, Hill-frame pointing - Debris 1 (
scObject2) — two free-spinning RWs, passive tumble, in a 2:1 centered ellipse relative to the servicer - Debris 2 (
scObject3) — inert rigid body, lead-follower configuration
Running the scenario
Step-by-step walkthrough
Create all spacecraft objects
Each spacecraft is an independent
Spacecraft instance with its own mass and inertia.Synchronize integration and set the integrator
By default each
Spacecraft integrates independently. Calling syncDynamicsIntegration makes the debris integration lock-step with the servicer. This matters when a dynamic effector couples both objects.Only the primary spacecraft (the one you called
syncDynamicsIntegration on) should have its integrator changed after syncing. Trying to change the secondary’s integrator will raise an error.Add reaction wheels to the servicer and free-spin RWs to debris
The servicer carries three controlled Honeywell HR16 RWs. The debris object has two freely spinning RWs — no motor torque is applied to them.
Set up navigation and Hill-frame guidance
The servicer uses
hillPoint rather than inertial3D — it aligns the spacecraft body to the Hill (LVLH) frame.Set initial orbital conditions for all spacecraft
The debris objects start in a 2:1 Hill-frame ellipse and lead-follower configuration relative to the servicer.
Module execution order
For correct dynamics, modules must execute in this order within each time step:AddModelToTask() to schedule a module earlier in the step.
Vizard support
The scenario includesvizSupport.enableUnityVisualization() with all three spacecraft. Vizard renders each body using its ModelTag as the display name. Camera and light instruments can be attached to any spacecraft via vizSupport helper calls before InitializeSimulation().