Skip to content
Back to skills

Lqr Design

ASecurity

Use when you must design an LQR state-feedback gain matrix for a scalar-input two-state system such as spacecraft attitude control: solve the algebraic Riccati equation for the cost weights, compute the gain matrix, verify closed-loop stability of the regulated system, and assess the Q over R weighting trade. Produces the Riccati solution, the gain vector, and the stability verdict that feed the control-law design. Trigger: lqr, linear quadratic regulator, riccati equation, gain matrix, state...

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 27, 2026
ai-agentspython

Works with

  • claude code

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 27, 2026

npx -y skills add ashfordeOU/aero-agent-skills --skill lqr-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lqr Design?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lqr Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ashfordeou-lqr-design/badge)](https://www.skillsdirectory.com/skills/ashfordeou-lqr-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: lqr-design
description: "Use when you must design an LQR state-feedback gain matrix for a scalar-input two-state system such as spacecraft attitude control: solve the algebraic Riccati equation for the cost weights, compute the gain matrix, verify closed-loop stability of the regulated system, and assess the Q over R weighting trade. Produces the Riccati solution, the gain vector, and the stability verdict that feed the control-law design. Trigger: lqr, linear quadratic regulator, riccati equation, gain matrix, state feedback, closed loop stability, control effort, spacecraft attitude control."
license: Apache-2.0
compliance: STANDARDS-REF
standards:
  - id: arp4754a
    reference-only: true
gated: false
domain: gnc-autonomy
pack: gnc-autonomy
compatibility: "agentskills.io SKILL.md; any SKILL.md host (Claude Code, Hermes, OpenClaw)"
metadata:
  domain: gnc-autonomy
  subdomain: optimal-control
  tags: [lqr-design, linear-quadratic-regulator, riccati, gain-matrix, state-feedback, closed-loop-stability, control-effort, spacecraft-attitude-control]
  version: 0.1.0
  author: Aero Agent Skills
---

# LQR Design (gnc-autonomy/optimal-control/lqr-design)

Use when the task is LQR state-feedback design for a scalar-input
two-state system: solving the Riccati equation, computing the gain
matrix, and verifying closed-loop stability.

## Domain quick reference

- LQR minimizes the quadratic cost J = integral(x'Qx + u'Ru) over the
  linear system x' = A x + B u; the optimal state feedback is u = -K x.
- The gain is K = R^-1 B' P with P the stabilizing solution of the
  algebraic Riccati equation A'P + PA - P B R^-1 B' P + Q = 0.
- For the canonical scalar-input two-state form A = [[0,1],[0,-a]],
  B = [0,1] (a damped double integrator), the Riccati equation reduces
  to a small closed-form system solved directly from q1, q2, r, and a.
- A 2x2 closed-loop matrix A - B K is stable exactly when its trace is
  negative and its determinant positive; the pole pair follows from the
  quadratic formula.
- Q penalizes state error and R penalizes control effort; their ratio
  sets the gain magnitude and the settling speed of the regulated
  system.
- ARP4754A (reference-only) frames development assurance for aircraft
  systems; the Riccati mathematics here is common control-theory
  knowledge.

## Workflow

1. Put the plant in canonical form: A = [[0,1],[0,-a]] with damping
   a >= 0, input B = [0,1], and pick cost weights Q = diag(q1, q2),
   R = r in one consistent SI convention (for an attitude plant: q1 in
   1/rad^2, q2 in 1/(rad/s)^2, r in 1/(N m)^2).
2. Solve the Riccati equation with riccati_gain for the symmetric
   matrix P.
3. Compute the gain with gain_matrix: K = R^-1 B' P, returned as
   [k1, k2].
4. Verify the closed loop with closed_loop_stable: eigenvalues of
   A - B K, reported as a stability verdict plus the pole pair.
5. Assess the weights with cost_weight_guide and re-tune q1, q2, r
   when the gains are too aggressive or too weak.

## Pitfalls

- Iterating the Riccati equation with the policy-iteration map
  P <- A'P + PA - P B R^-1 B' P + Q; that map is not a contraction and
  need not converge. Solve the ARE directly instead.
- Applying the closed form outside the canonical family: a general A
  and B need a general Riccati solver, not this leaf's equations.
- Mixing weight conventions (rad with deg, torque in N m with weights
  scaled for a different unit); the gain and the closed-loop poles
  change with the convention.
- Checking stability from the determinant alone; a 2x2 closed loop
  needs trace < 0 AND determinant > 0.
- Accepting negative q or nonpositive r; the module raises ValueError
  on impossible weights.

## Behavior contract (gate 3)

The Riccati solve, gain computation, closed-loop stability verdict,
and cost-weight guidance are exercised by the gate 3 contract test:
scripts/test_lqr_design_logic.py against scripts/lqr_design_logic.py
(stdlib unittest, offline). Run:
python3 scripts/test_lqr_design_logic.py

## Compliance

- ARP4754A is proprietary (SAE); name and paraphrase only per
  standards-map.yaml, reference-only: true.
- Revision note: ARP4754B (2023) supersedes ARP4754A; this skill keys to
  ARP4754A as the certification-baseline revision (FAA AC 20-174 cites A);
  see standards-map.yaml arp4754a.revision_decision.
- compliance: STANDARDS-REF, gated: false.

Files in this skill

  • SKILL.md4.3 KB
  • scripts/lqr_design_logic.py8.5 KB
  • scripts/test_lqr_design_logic.py7.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.