A real-time Hardware-in-the-Loop (HIL) simulation for spacecraft avionics — built in Python.
This project simulates a gyroscope sensor and a basic flight computer, allowing real-time interaction to modify signal parameters mid-simulation.
- Simulates gyroscope sensor with sine + Gaussian noise
- Real-time interactive control:
pause,resume,stop, and change signal parameters - Decision logic to simulate basic flight computer actions
- Outputs:
- Time-series plot of gyroscope data with control thresholds
- Command log file
- Sensor model generates a noisy sine-wave signal as gyroscope output.
- Flight computer analyzes the signal and makes decisions like:
Activate DampersStabilize YawHold Position
- You can interact with the simulation in real time via terminal input:
pause,resume,stopamp <value>,freq <value>,noise <value>
- Python 3.x
numpymatplotlib
Install required libraries:
pip install numpy matplotlibpython Spacecraft_HIL_Simulation.pyDuring simulation, you can type:
pause— Pauses simulationresume— Resumes simulationstop— Ends simulationamp 1.5— Set signal amplitudefreq 0.8— Set signal frequencynoise 0.2— Set noise standard deviation
gyro_data_interactive.png— Plot of gyroscope readings vs. timehil_simulation_log.txt— Logged commands and readings in CSV format
Spacecraft_HIL_Simulation/
├── hil_simulation.py # Main simulation file
├── README.md # This file
├── gyro_data_interactive.png # Output plot (auto-generated)
└── hil_simulation_log.txt # Output log (auto-generated)
- Add GUI using Streamlit or Tkinter
- Simulate more sensors (e.g., accelerometers, magnetometers)
- Integrate with real spacecraft hardware for testing
Arhaan Khan
This project is licensed under the MIT License.
Made with 💡 for simulation testing, space systems learning, and real-time control exploration.
