SatelliteSimulator Base Class - HIL Foundation
- ✅ TelemetryPacket Pydantic model with timestamp, satellite_id, data
- ✅ SatelliteSimulator abstract base class with:
generate_telemetry()abstract methodinject_fault()abstract methodstart()/stop()lifecycle methodsget_telemetry_history()utilityrecord_telemetry()internal recorder
- ✅ StubSatelliteSimulator concrete stub with:
- Realistic LEO telemetry generation (520km altitude)
- Voltage drop simulation (8.4V → 6.5V on power_brownout)
- Temperature variance ±5°C
- Nadir-pointing attitude quaternion
- ✅
test_base_class_structure()- Validates packet structure and fault injection - ✅
test_lifecycle()- Verifies start/stop state management - ✅
test_telemetry_history()- Tests history tracking and copy semantics - ✅
test_fault_injection_voltage_drop()- Validates voltage drop behavior - ✅
test_multiple_satellites()- Ensures independent simulator instances - Test Results: 5/5 PASSED ✓
Demonstrates:
- ✅ Simulator initialization and lifecycle
- ✅ Normal operation telemetry (8.4V nominal)
- ✅ Fault injection (power_brownout)
- ✅ Post-fault telemetry (6.5V degraded)
- ✅ History tracking with 8 recorded packets
| Criterion | Status |
|---|---|
hil/simulator/base.py exists |
✅ |
| TelemetryPacket Pydantic model | ✅ |
| abstract methods (generate_telemetry, inject_fault) | ✅ |
| lifecycle utilities (start/stop/history) | ✅ |
| StubSatelliteSimulator for testing | ✅ |
| pytest tests pass | ✅ (5/5) |
| demo script runs | ✅ |
| Realistic LEO values | ✅ (520km, voltage, temp) |
| Voltage drop on fault | ✅ (6.5V during brownout) |
tests/hil/test_simulator_base.py::test_base_class_structure PASSED
tests/hil/test_simulator_base.py::test_lifecycle PASSED
tests/hil/test_simulator_base.py::test_telemetry_history PASSED
tests/hil/test_simulator_base.py::test_fault_injection_voltage_drop PASSED
tests/hil/test_simulator_base.py::test_multiple_satellites PASSED
======================== 5 passed in 0.78s ========================
✓ Initialized simulator: DEMO-SAT
✓ Normal operation: 5 packets @ 8.4V
✓ Fault injection: power_brownout (severity=0.8, duration=30.0s)
✓ Post-fault: 3 packets @ 6.5V
✓ History: 8 packets recorded
✓ Simulator stopped
- #486: Telemetry schemas (TelemetryPacket can migrate from base.py)
- #487: Attitude generator (inherits SatelliteSimulator)
- #488: Power emulator (inherits SatelliteSimulator)
- All 20-PR HIL backend sprint now unblocked
astraguard/
├── hil/
│ ├── __init__.py
│ ├── simulator/
│ │ ├── __init__.py
│ │ └── base.py ⭐
│ └── schemas/
│ └── __init__.py
tests/
└── hil/
├── __init__.py
└── test_simulator_base.py ⭐
examples/
└── hil_demo_485.py ⭐
feat(hil): add SatelliteSimulator base class (#485)
- Abstract SatelliteSimulator with telemetry/fault interfaces
- Stub implementation for immediate testing
- Pydantic TelemetryPacket model
- Lifecycle methods + history tracking
- Tests + demo script
Closes #485
90 minutes (per spec) ✅
Status: READY FOR MERGE ✅