🎯 LQR Controller Calculator optimal gain design
🔷 A (state matrix)
🔶 B (input matrix)
🎯 LQR (Linear Quadratic Regulator) Calculator
This tool computes the optimal state-feedback gain matrix K for a linear system:
ẋ = Ax + Bu → u = -Kx
📐 Cost function: J = ∫ (xᵀ Q x + uᵀ R u) dt
🔧 System: 2nd-order (mass-spring-damper) by default
🎛️ Tuning:
• Q – penalizes state errors (position, velocity)
• R – penalizes control effort
📊 Results:
• K – optimal feedback gains
• Poles – closed-loop system stability
• Simulation – shows response from initial condition
💡 Tip: Higher Q → faster response, higher R → smoother control.
📖 LQR Controller – detailed explanation
🔬 What is LQR?
The Linear Quadratic Regulator (LQR) is an optimal control method that computes a state-feedback gain matrix K to minimize a quadratic cost function. It's widely used in robotics, aerospace, automotive, and industrial control.
📐 Mathematical formulation:
For a linear time-invariant system ẋ = Ax + Bu, LQR finds the control law u = -Kx that minimizes:
J = ∫₀^∞ (xᵀ Q x + uᵀ R u) dt
🔧 Default system (mass-spring-damper):
• State: x = [position, velocity]ᵀ
• A = [[0, 1], [-k/m, -b/m]]
• B = [[0], [1/m]]
• Default: m=1, k=2, b=1 → A = [[0,1], [-2,-1]], B = [[0],[1]]
🎯 Tuning LQR:
• Q matrix (2×2): penalizes state deviations. Default Q = diag(1, 0.1)
• R matrix (1×1): penalizes control effort. Default R = 0.1
• Larger Q → faster response, more aggressive control
• Larger R → smoother control, slower response
🧪 Interactive features:
• Edit A and B matrices directly
• Tune Q and R in real-time
• Compute optimal gain K instantly
• View closed-loop poles and stability
• Simulate system response from initial condition
• Visualize position, velocity, and control effort
⚡ Built for education · works offline · no server

0 Comments