Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Latest commit

 

History

History
113 lines (96 loc) · 3.6 KB

File metadata and controls

113 lines (96 loc) · 3.6 KB

✅ Issue #485 Implementation Complete

SatelliteSimulator Base Class - HIL Foundation

📦 Deliverables

1. Core Implementation: astraguard/hil/simulator/base.py

  • TelemetryPacket Pydantic model with timestamp, satellite_id, data
  • SatelliteSimulator abstract base class with:
    • generate_telemetry() abstract method
    • inject_fault() abstract method
    • start() / stop() lifecycle methods
    • get_telemetry_history() utility
    • record_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

2. Tests: tests/hil/test_simulator_base.py

  • 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 ✓

3. Demo: examples/hil_demo_485.py

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

🎯 Acceptance Criteria

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)

📊 Test Output

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 ========================

🚀 Demo Output

✓ 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

🔗 Unblocks

  • #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

📋 File Structure

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 ⭐

🎨 Commit Message

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

⏱️ Time to Completion

90 minutes (per spec) ✅


Status: READY FOR MERGE ✅