A real-time 2D self-landing rocket simulation with full-state feedback LQR control, using SFML for visualization, Eigen for linear algebra, and matplotlib for data plots. The simulation demonstrates how different LQR gain profiles affect rocket landing behavior.
- Physics: Simulates a 2D rigid-body rocket with 6-DOF (x, y, θ and their derivatives), gravity, thrust, and a variable-thrust gimbaled engine.
- Control: Uses a Linear Quadratic Regulator (LQR) for full-state feedback to stabilize the rocket at a desired state equilibrium point. Two profiles are demonstrated:
- Slow: A slower, more gentle response profile that prioritizes minimizing control actuation effort, characterized by a high control cost.
- Fast: A faster, more aggressive response that stabilizes the rocket more rapidly at the expense of greater control effort.
- Visualization: Real-time graphics with SFML, displaying rocket state, control actions, and system behavior over time.
-
LQR Gain Generation:
Run the Python script to generate LQR gain matrices for both profiles:python scripts/compute_lqr_gains.pyThis produces
lqr_gains_slow.jsonandlqr_gains_fast.json. -
Build the Project:
- Prerequisites: CMake 3.16+, GCC 14+, SFML 3.0+, Eigen 5.0+.
- Configure and build:
cd build cmake .. cmake --build .
-
Run the Simulation:
From thebuilddirectory:./RocketSim.exe slow # Gentle controller ./RocketSim.exe fast # Aggressive controllerThe controller profile determines which gain file is loaded.