AgentSkillsCN

robotics

从经过验证的 TypeScript 参考中,生成原生的机器人学库——包括运动学、IK 解算器、状态估计、PID 调参、路径规划、驱动系统模型、LQR、MPC、SLAM——

SKILL.md
--- frontmatter
name: robotics
description: Generate a native robotics library — kinematics, IK solvers, state estimation, PID tuning, path planning, drivetrain models, LQR, MPC, SLAM — from a verified TypeScript reference
argument-hint: "<nodes> [--lang <language>] or 'help' — e.g. 'kalman-filter --lang python' or 'help'"
allowed-tools: ["Bash", "Read", "Write", "Edit", "Glob", "Grep"]

Robotics Skill

A modular robotics library covering six domains: state estimation (Kalman, EKF, UKF, particle filter), kinematics (DH forward kinematics, Jacobian IK, CCD, FABRIK), control (PID with auto-tuning, LQR, MPC, pure pursuit, Stanley), path planning (A*/Dijkstra, RRT, RRT*, PRM, D* Lite), drivetrain models (differential, mecanum, swerve, Ackermann), and SLAM (pose graph optimization).

When to use this skill

When you need robotics algorithms without adding a robotics framework dependency. Covers core algorithms from Robotics Toolbox (Corke), FilterPy, python-control, PythonRobotics, and OMPL, implemented from scratch with clear provenance.

Arguments

$ARGUMENTS has the format: <nodes> [--lang <language>]

  • nodes: Space-separated list of node names to translate, or all for every node. Dependencies are resolved automatically — specify only the nodes you want.
  • --lang: Target language (e.g. python, rust, go, cpp, csharp, swift, kotlin, typescript). Defaults to typescript if omitted.

Examples:

  • kalman-filter --lang python — translate just the Kalman filter subset to Python
  • jacobian-ik --lang cpp — translate the full Jacobian IK pipeline to C++
  • differential-drive pure-pursuit --lang rust — translate a mobile robot subset to Rust
  • all --lang go — translate the full library to Go

Node Graph

code
                              ┌── result-types ──────────────────────────────────────┐
                              │        │                                             │
                              │        ├──→ pid                                      │
                              │        ├──→ fopdt-model                              │
                              │        ├──→ pid-tuning-rules                         │
                              │        ├──→ relay-analysis                            │
                              │        ├──→ fabrik                                    │
                              │        ├──→ particle-filter                           │
                              │        ├──→ graph-search                              │
                              │        ├──→ rrt ──────────→ rrt-star                  │
                              │        │    └──────────────→ prm                      │
                              │        ├──→ d-star                                    │
                              │        │                                             │
drivetrain-types ─────────────┤        │    ┌── plan-path ←── any-of(graph-search,   │
    ├──→ differential-drive   │        │    │                  rrt, rrt-star, prm,    │
    ├──→ mecanum-drive        │        │    │                  d-star)                │
    ├──→ swerve-drive         │        │    │                                        │
    ├──→ ackermann            │        │    └── solve-ik ←── any-of(jacobian-ik,     │
    │                         │        │                      ccd, fabrik)            │
    ├──→ pure-pursuit ←───────┘        │                                             │
    └──→ stanley-controller ←──────────┘                                             │
                                                                                     │
mat-ops ──────────────────────────────────────────────────────────────────────────────┘
    │                                                                     │
    ├──→ rotation-ops ──→ transform-ops                                   │
    │         │                │                                          │
    │         │                ├── (+ dh-parameters) ──→ forward-kinematics
    │         │                │                              │           │
    │         │                │                           jacobian       │
    │         │                │                              │           │
    │         │                ├── (+ forward-kin) ──→ jacobian-ik ←──────┘
    │         │                └── (+ forward-kin) ──→ ccd ←─────────────┘
    │         │
    ├──→ dh-parameters                     ┌── test-chains ←── dh-parameters
    │                                      │
    ├──→ state-types                       └── test-scenarios ←── result-types
    │       ├──→ kalman-filter
    │       ├──→ ekf
    │       ├──→ ukf
    │       └──→ estimate-state ←── any-of(kalman-filter, ekf, ukf)
    │
    ├──→ lqr
    ├──→ mpc ←── state-types, result-types, optimization:bfgs
    └──→ pose-graph-optimization

Nodes

NodeTypeDepends OnDescription
mat-opsleafMatrix arithmetic: multiply, transpose, inverse, solve, Cholesky, eigen, SVD
rotation-opsinternalmat-opsRotation matrices, quaternions (Hamilton w,x,y,z), Euler angles (ZYX)
transform-opsinternalmat-ops, rotation-opsSE(3) homogeneous transforms: compose, invert, transform point
result-typesleafCommon result types: IKResult, PlanResult, ControlOutput, PIDState
state-typesinternalmat-opsGaussianState (mean + covariance), Pose2D, Pose3D
drivetrain-typesleafWheelConfig, DrivetrainGeometry, WheelSpeeds
dh-parametersinternalmat-opsDH parameter representation and single-joint transform (standard convention)
forward-kinematicsinternalmat-ops, rotation-ops, transform-ops, dh-parametersEnd-effector pose from joint angles and DH chain
jacobianinternalmat-ops, rotation-ops, transform-ops, dh-parameters, forward-kinematicsGeometric Jacobian for serial manipulators
jacobian-ikinternalmat-ops, rotation-ops, transform-ops, forward-kinematics, jacobian, result-typesDamped least-squares IK using the geometric Jacobian
ccdinternalrotation-ops, transform-ops, forward-kinematics, result-typesCyclic Coordinate Descent IK: joint-by-joint optimization
fabrikinternalresult-typesFABRIK IK: geometric solver in Cartesian space (no DH needed)
solve-ikrootresult-types, any-of(jacobian-ik, ccd, fabrik)IK dispatcher: selects solver by method parameter
kalman-filterinternalmat-ops, state-typesLinear Kalman filter: predict + update
ekfinternalmat-ops, state-typesExtended Kalman Filter with user-provided Jacobians
ukfinternalmat-ops, state-typesUnscented Kalman Filter (Van der Merwe scaled sigma points)
particle-filterinternalresult-typesSequential Monte Carlo with systematic resampling
estimate-staterootstate-types, any-of(kalman-filter, ekf, ukf)Estimation dispatcher: selects filter by method parameter
pidinternalresult-typesPID controller with anti-windup (clamping) and derivative filtering
fopdt-modelinternalresult-typesFOPDT model type and step-response identification (K, τ, θ)
pid-tuning-rulesinternalresult-typesZiegler-Nichols, Cohen-Coon, Tyreus-Luyben, SIMC, Lambda, IMC tuning
relay-analysisinternalresult-typesExtract Ku and Tu from relay feedback data (Åström-Hägglund)
lqrinternalmat-opsLinear-quadratic regulator via DARE (Schur decomposition)
mpcinternalmat-ops, state-types, result-types, optimization:bfgsModel predictive control (receding-horizon NLP)
pure-pursuitinternalresult-types, drivetrain-typesGeometric path follower with fixed lookahead
stanley-controllerinternalresult-types, drivetrain-typesFront-axle crosstrack error controller
differential-driveinternaldrivetrain-typesTwo-wheel differential kinematics (forward + inverse)
mecanum-driveinternaldrivetrain-typesFour-wheel mecanum omnidirectional kinematics
swerve-driveinternaldrivetrain-typesFour-wheel swerve with independent steering
ackermanninternaldrivetrain-typesBicycle model Ackermann steering geometry
graph-searchinternalresult-typesA* and Dijkstra on 2D grids
rrtinternalresult-typesRapidly-exploring Random Tree path planner
rrt-starinternalresult-types, rrtAsymptotically optimal RRT with rewiring
prminternalresult-types, rrtProbabilistic Roadmap for multi-query planning
d-starinternalresult-typesD* Lite for replanning in dynamic environments
plan-pathrootresult-types, any-of(graph-search, rrt, rrt-star, prm, d-star)Planning dispatcher: selects planner by method parameter
pose-graph-optimizationinternalmat-opsSE(2) pose graph SLAM via Gauss-Newton
test-chainstestdh-parametersTest DH chains: 2-link planar, 3-link spatial, PUMA 560
test-scenariostestresult-typesTest fixtures: grids, trajectories, measurement sequences

Subset Extraction

  • Just Kalman Filter: mat-ops + state-types + kalman-filter (3 nodes)
  • Just EKF: mat-ops + state-types + ekf (3 nodes)
  • Just PID: result-types + pid (2 nodes)
  • PID Tuning: result-types + pid + fopdt-model + pid-tuning-rules (4 nodes)
  • Just FABRIK: result-types + fabrik (2 nodes)
  • Jacobian IK: mat-ops + rotation-ops + transform-ops + dh-parameters + forward-kinematics + jacobian + jacobian-ik + result-types (8 nodes)
  • Just LQR: mat-ops + lqr (2 nodes)
  • Just RRT: result-types + rrt (2 nodes)
  • Diff-drive + pursuit: result-types + drivetrain-types + differential-drive + pure-pursuit (4 nodes)
  • MPC: mat-ops + state-types + result-types + mpc + optimization:bfgs (4 nodes + cross-skill)
  • Full library: all 37 non-test nodes
  • Test nodes are optional — only needed for validation

Handling help

When $ARGUMENTS is help, read HELP.md and use it to guide the user through node and language selection. The help guide contains a decision tree covering robot type, task domain, common profiles (FRC, FTC, MATE, undergrad, hobbyist), and language idioms. Walk through it interactively, asking the user about their requirements, then recommend specific nodes and a target language.

Translation Workflow

For each node in dependency order:

  1. If $ARGUMENTS is help, read HELP.md and guide the user interactively
  2. Read the node spec at nodes/<name>/spec.md for behavior, API, and test vectors
  3. Read language-specific hints at nodes/<name>/to-<lang>.md if available
  4. Generate the implementation and tests in the target language
  5. If the spec is ambiguous, consult the TypeScript reference at reference/src/<name>.ts

The reference code is TypeScript with 100% line and function coverage. Every node has a corresponding test file at reference/src/<name>.test.ts that serves as the behavioral contract.

Cross-Skill Dependencies

The mpc node depends on optimization:bfgs — the BFGS optimizer from the optimization skill. When translating mpc:

  1. Check if the optimization skill is installed
  2. If not, prompt: "The mpc node depends on bfgs from the optimization skill. Install it?"
  3. Resolve the transitive closure of bfgs within the optimization skill
  4. Generate both skills' nodes into a single output

Key Design Decisions (Off-Policy)

These defaults differ across robotics libraries. Our choices with provenance:

DecisionOur ValueAlternativesProvenance
Quaternion conventionHamilton (w,x,y,z)ROS 2 (x,y,z,w), JPL (x,y,z,w)Matches Eigen, Rotations.jl; ROS reorder at boundary
DH conventionStandard (1955)Modified (Craig)Matches Corke, KDL; Craig conversion documented
Euler orderZYX (yaw-pitch-roll)XYZ, ZXZAerospace/robotics standard
Angle unitsRadiansDegreesSI standard; no deg↔rad in API
UKF sigma pointsVan der Merwe (α=0.001, β=2, κ=0)Julier (α=1, β ̇=0, κ=3-n)FilterPy default; matches most tutorials
PID anti-windupIntegral clampingBack-calculation, conditional integrationSimplest; universal applicability
PID derivativeFilter on error derivativeDerivative of PV, unfilteredReduces derivative kick; industry standard
FOPDT identificationStep response (63.2% method)Area method, Smith methodÅström & Hägglund 2006, most common
RRT goal bias0.050.1–0.3OMPL default; low bias = better exploration
RRT step size0.5Problem-dependentReasonable default; user should tune
A* heuristicEuclideanManhattan, octileAdmissible for continuous-cost grids
D* LiteOptimized versionBasic versionKoenig & Likhachev 2002
Particle filter resamplingSystematicMultinomial, residual, stratifiedLow variance; O(n)
LQR solverDARE via SchurIterative Riccati, eigendecompositionNumerically stable; matches python-control
MPC solverBFGS (cross-skill)SQP, IPOPT, direct collocationMatches available optimization skill
Pose graph solverGauss-NewtonLevenberg-Marquardt, gradient descentStandard for SLAM; matches GTSAM approach

Error Handling

  • IK solvers: return IKResult with converged=false if max iterations exceeded
  • Filters: no exceptions; invalid covariance matrices are caller's responsibility
  • Planners: return PlanResult with success=false if no path found
  • PID: output clamping prevents unbounded output; integral clamping prevents windup
  • LQR: throws if DARE does not converge (system not stabilizable)
  • MPC: returns result with converged=false if optimizer fails
  • Drivetrains: pure kinematic transforms — no error states
  • Pose graph: returns with iteration count if max iterations exceeded

Cross-Validation Targets

DomainPrimary LibrarySecondary Library
State estimationFilterPy v1.4.4LowLevelParticleFilters.jl v3.29.4
KinematicsRobotics Toolbox (Corke) v1.1.0RigidBodyDynamics.jl v2.3.2
PID / tuningpython-control v0.10.2Åström & Hägglund (textbook tables)
Path planningPythonRoboticsOMPL v1.7.0
LQRpython-control v0.10.2ControlSystems.jl v1.15.2
DrivetrainsPythonRoboticsROS 2 nav2
SLAMGTSAM 4.2
RotationsRotations.jl v1.7.1Eigen (quaternion ops)