Linear Quadratic Regulator (LQR)

lqr____
LQR Control · Linear Quadratic Regulator simulator

🎯 LQR Control Linear Quadratic Regulator

⚡ state‑feedback control · mass‑spring‑damper · interactive
1.0 2.0 1.0
⏱️ 0.00s 📍 pos: 3.00 m 🚀 vel: 0.00 m/s control: 0.00 N 0%
K = [ 0.00 0.00 ]

🎯 LQR (Linear Quadratic Regulator)
LQR is an optimal control technique that computes state-feedback gains to minimize a quadratic cost function:

J = ∫ (xᵀ Q x + uᵀ R u) dt

System: mass-spring-damper (2nd order)
States: position (x) and velocity (v)
Control: force (u) applied to the mass

🎛️ Parameters:
Mass (m): inertia of the system
Spring (k): restoring force (stiffness)
Damping (b): energy dissipation
Q: weight on state error (position + velocity)
R: weight on control effort

💡 Tip: Higher Q → faster response, higher R → smoother control. Click Run to simulate, Reset to restart.

📖 LQR Control – detailed explanation

🔬 What is LQR?
The Linear Quadratic Regulator (LQR) is a powerful optimal control method used in robotics, aerospace, automotive, and many other fields. It computes a state-feedback gain matrix K that minimizes a quadratic cost function.

📐 Mathematical formulation:
For a linear system ẋ = Ax + Bu, LQR finds the control law u = -Kx that minimizes:
J = ∫₀^∞ (xᵀ Q x + uᵀ R u) dt

🔧 System model (mass-spring-damper):
• State vector: x = [position, velocity]ᵀ
• A = [[0, 1], [-k/m, -b/m]]
• B = [[0], [1/m]]

🎯 Tuning LQR:
Q matrix (state cost): penalizes deviation from zero state
R matrix (control cost): penalizes control effort
• Larger Q → faster response but more aggressive control
• Larger R → smoother control but slower response

🧪 Interactive features:
• Adjust mass, spring, damping using sliders
• Tune Q and R in real-time
• See the computed gain matrix K
• Visualize position, velocity, and control force
• Step-by-step or continuous simulation

⚡ Built for education · works offline · no server

Post a Comment

0 Comments