How ltstrange/satellite-simulator works
Project Type and Purpose
• This is a Rust-based satellite simulator application built on the Bevy game/graphics engine.
• It is organized as a Cargo workspace with three crates:
• brp_packages: a library crate (likely shared utilities or data packages)
• orbiter: a library crate handling orbital mechanics calculations and tests
• simulator: the main executable crate that ties together configuration, data I/O, the simulation core, networking, and 3D visualization
High-Level Architectural Components
a. Configuration & Data Input
• Reads config.toml for simulation parameters (dataset paths, network port, display toggles, simulation speed, link thresholds).
• Loads JSON constellation files (e.g. starlink.json, Iridium.json) into in-memory data structures.
b. Core Simulation Engine
• Core modules under simulator/src/core/:
• orbit.rs: propagates satellite positions using orbital mechanics
• satellite.rs: holds satellite state (position, velocity, energy, tasks)
• communication.rs: models link establishment & tear-down based on distance
• manager.rs: orchestrates update loop, invokes orbit and communication each tick
• Uses utilities from orbiter and brp_packages crates for calculations.
c. I/O & Network Interface
• simulator/src/io/: abstracts reading/writing data, exposing a network interface (listening on configured port) for external clients (e.g., Python bindings).
• Allows real-time retrieval of simulation state.
d. Visualization Layer (UI)
• Built with Bevy ECS under simulator/src/ui/:
• display_toggle.rs & fps.rs: UI controls & status overlays
• widgets/*: interactive buttons and toggles for orbit paths and link display
• Renders satellites, orbits, and dynamic communication lines in 3D.
• Camera controls in camera.rs.
e. Entry Point
• simulator/src/main.rs initializes Bevy app, loads config & data, registers systems for core simulation, I/O server, and UI rendering.
Relationships & Data Flow
• On startup: main → config module → read config.toml → load JSON data → pass to core manager
• Per frame (64 Hz):
• Core manager updates all satellite orbits (calls orbital library)
• Communication module checks/updates ISLs
• Simulation state is stored/updated in ECS resources
• UI systems query ECS resources to render satellites, orbits, and link lines
• I/O/server system packages state snapshots and sends over TCP/UDP to external clients
• External: JSON files and config toml supply initial data; Python client (future) connects to network port.
Architectural Patterns & Design Principles
• Modular library crates (orbiter, brp_packages) for reusability and separation of concerns
• Bevy’s ECS (Entity-Component-System) pattern for simulation state and rendering decoupling
• Clear separation: Configuration → Core Simulation → Visualization → Networking
• Data-driven: JSON and TOML files define orbits and simulation parameters
• Single executable orchestrator (simulator) with pluggable modules