Skip to main content

About Moonlander

Recent Updates

  • Implemented an Adaptive Descent Controller for automated landing
  • Controller uses an energy-based guidance law to compute safe descent trajectories
  • Introduced brake ratio based descent mode switching for adaptive control behavior
  • Added PD velocity control with gravity compensation and thrust saturation handling
  • Implemented phase-based descent logic enabling stable landing across multiple descent regimes
  • Added a Spacecraft Selection interface allowing users to choose between multiple spacecraft configurations before starting the simulation
  • Introduced a JSON-based spacecraft configuration system enabling easy definition of spacecraft parameters without recompiling the simulation
  • Implemented a centralized ConfigManager responsible for loading and distributing configuration data across the UI

Project Overview

Moonlander is an educational and research-oriented C++ project simulating lunar landings. Inspired by classical "Lunar Landing" examples, it combines rigorous physics-based simulation with an interactive Qt-based frontend. The simulation environment allows exploration of one-dimensional vertical descent as well as future multi-dimensional extensions.

The project emphasizes modularity: the backend handles physics calculations, state propagation, and control logic, while the frontend provides real-time telemetry, cockpit visualization, spacecraft configuration, and interactive user control.

Spacecraft configurations are defined externally via JSON files, enabling new spacecraft variants to be added without modifying the simulation code.

Frontend & Backend Architecture

The backend implements the lander's dynamics, numerical integration, sensors, optimization, and control loop in a thread-safe C++ simulation engine. It is fully decoupled from the UI, providing a robust foundation for automated testing, optimization, and interactive operation.

Key backend components include:

  • Automation: IAutopilot, AdaptiveDescentController (energy-based landing with brake ratio guidance)
  • Control: InputArbiter (decides whether manual or autopilot control is active)
  • Controller: IController, PD_Controller (supports autopilot)
  • Integrators: IIntegrator, EulerIntegrator, Dynamics
  • Physics Models: IPhysicsModel, BasicMoonGravity, Physics (orchestrator)
  • Sensors & Perception: ISensor, SensorModel
  • Optimization: OptimizationModelParams, OptimizationStruct, ThrustOptimizationProblem, ThrustOptimizer
  • Thrust & Spacecraft: Thrust, CustomSpacecraftStruct, Spacecraft, SpacecraftStateStruct, StateVectorStruct, Quaternion, Vector3
  • Configuration: ConfigManager responsible for loading spacecraft definitions from JSON configuration files
  • Simulation Control: SimControl coordinating simulation steps and data flow
  • Environment & Utilities: EnvironmentConfig, JsonConfigReader, SimDataStruct, Logger, Spacemath (deprecated), Output (deprecated)

The frontend, built with Qt, visualizes the lander state in real time, including altitude, velocity, thrust, fuel, and proper g-load. Users can interact with the simulation through the cockpit interface and select spacecraft configurations before entering the simulation.

The SpacecraftSelectionPage allows users to choose between different spacecraft profiles defined in the JSON configuration. The selected spacecraft configuration is then forwarded to the simulation backend to initialize the spacecraft model.

Current Features

  • Full separation of backend physics engine, integrators, optimization, and frontend UI for modular development
  • Real-time telemetry and cockpit visualization of altitude, velocity, thrust, fuel, and g-load
  • Thread-safe simulation loop with precise timing and Qt signal-slot integration
  • Integrated logging system capturing backend debug output independently from the UI
  • Configurable parameters via JSON for spacecraft and simulation settings
  • Multiple spacecraft configurations selectable through JSON configuration files
  • ConfigManager providing centralized access to spacecraft configuration data
  • Interactive user controls with slider-based thrust adjustment and simulation management
  • Experimental 1D thrust optimization using NLopt to minimize fuel while ensuring safe landing
  • Adaptive Descent Controller for automated, phase-based landing guidance
  • Support for future multi-dimensional dynamics and orbital maneuvers

Adaptive Descent Controller

The Adaptive Descent Controller is a modular system that guides the spacecraft safely during the final descent. It evaluates the current spacecraft state and dynamically adjusts thrust commands to ensure a smooth and stable landing trajectory.

Core Concepts

  • Brake Ratio: Compares the remaining altitude to the distance needed to safely decelerate.
  • Descent Phases: The controller switches between multiple phases depending on the brake ratio: MODE_A (Energy Dissipation), MODE_B (Controlled Descent), MODE_C (Terminal Approach), MODE_D (Critical Braking).
  • Guidance and Control: Uses predictive guidance combined with feedback control to maintain safe velocity targets.
  • Characteristics: Adaptive gain scheduling, gravity compensation, thrust limits handling, and robust landing behavior.

Thrust Optimization (Experimental)

Moonlander now includes a backend module for 1D thrust optimization:

  • Goal: Minimize fuel consumption while achieving target altitude and safe landing velocity
  • Forward simulation uses EulerIntegrator to propagate spacecraft state under candidate thrust profiles
  • Cost function accounts for terminal state, fuel usage, thrust smoothness, and descent encouragement
  • Current status: Evaluates thrust sequences but still under tuning; mass floor enforcement prevents non-physical negative mass
  • Next steps: Stabilize optimizer convergence, adjust cost weights, and integrate physical thrust limits

Goals & Future Vision

Moonlander aims to provide a robust, extensible platform for learning and experimentation in aerospace physics, spacecraft control systems, and optimization.

  • Extension to multi-dimensional dynamics and orbital maneuvers
  • Advanced control experiments, including closed-loop guidance and fuel-optimal automated landing
  • Simulation of multiple landers or spacecraft in coordinated scenarios
  • Enhanced visualization with 3D cockpit and landing views
  • Integration with additional telemetry outputs for data analysis and validation
  • Replay and record simulation sessions for research and teaching purposes

The overarching goal is to create a platform that is educational, research-ready, and supports modular UI development, accurate physics simulation, and meaningful experimentation with spacecraft dynamics and control algorithms.