GNC Debugging Lab — Fixing a 2D Spacecraft Simulation

This page develops a spacecraft GNC debugging workflow as an interactive engineering lab, connecting broken dynamics, state-bus interfaces, PD attitude control, chaser guidance, mode switching, and disturbance response in one coherent flow.

GNC Debugging Lab

This lab is designed as an interactive engineering exercise. Instead of only reading a solved problem, the student tests an incorrect model, observes what fails, applies the correct fix, and checks the result.

The lab follows a simplified 2D spacecraft GNC workflow: rotational-state propagation, SatelliteBus consistency, attitude control, chaser guidance, mode switching, and disturbance comparison.

Try → Observe → Diagnose → Fix → Validate → Learn
Stage 1 — Rotational Dynamics Debugger

Problem

A spacecraft has an applied moment that produces angular acceleration \( \dot{\omega} \). The task is to decide how the attitude state should be propagated before it is sent to the controller.

Choose a model:

What to notice

The incorrect model sends angular acceleration directly into orientation. That skips angular velocity, so the attitude state is incomplete.

Correct rotational chain:

\( \dot{\omega} = \alpha \)
\( \dot{\theta} = \omega \)
Stage 2 — SatelliteBus Checker

Problem

A controller can only use the states that are exposed to it. If the bus is missing a key variable, the controller may fail even if the internal dynamics are correct.

Engineering lesson

For attitude control, orientation alone is not enough. A PD controller also needs angular velocity so the derivative term can damp the response.

Required attitude state:

\( \text{state}_{attitude} = [\theta,\ \omega] \)
Stage 3 — Attitude Control PD Tuning

Problem

After fixing the rotational state, the spacecraft can now be controlled. Tune a PD controller so the spacecraft tracks a target attitude.

\( \tau = K_p(\theta_{target} - \theta) - K_d\omega \)




Stage 4 — Chaser–Target Relative Navigation

Problem

Satellite 2 acts as the chaser and must reduce its distance from Satellite 1. The controller uses relative position and velocity feedback.









Stage 5 — State-Machine Threshold Test

Problem

A chaser spacecraft changes behaviour depending on its distance from the target. This test shows how APPROACH, RENDEZVOUS, and STATION_KEEP modes change as thresholds are adjusted.





Stage 6 — Disturbance On/Off Comparison

Problem

Disturbances such as drag, solar pressure, and noise may change the chaser response. This simplified comparison shows whether the controller remains stable when small disturbances are enabled.