Adaptive cruise control

From XuShuwenn/RedAct · View interactive version

Adaptive cruise control is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Implement adaptive cruise control systems with PID controllers for vehicle speed and distance regulation.

How to use this skill

Skill file

Adaptive Cruise Control

When to Use

Key Concepts

Workflow

  1. Read vehicle parameters from YAML (mass, acceleration limits, etc.) and confirm the actual schema before using keys in code; do not assume sections such as simulation or fields such as dt exist unless verified.

Preserve the task's required runtime interfaces, file roles, class/function signatures, and runtime loading paths instead of hard-coding values or collapsing files for convenience.

  1. Read sensor data (time, ego_speed, lead_speed, distance) and inspect enough of the dataset to map regime changes, signal availability over time, row count, timestep behavior, missing-data patterns, and when lead-vehicle interaction first becomes valid/present; do not infer missing signals from only the first few rows.
  1. Implement PID controller class with configurable gains, and keep controller behavior, ACC mode/safety logic, and simulation/evaluation orchestration separated so gains, mode conditions, and metrics can change without entangling plant updates.
  1. Implement ACC system with cruise/follow/emergency modes from the stated spec/config; in follow mode, make spacing/safety control the primary objective and use speed regulation only as a limiter/cap unless the task specifies a different control law. Handle mode transitions explicitly by resetting or reinitializing PID state as needed to avoid derivative kick or stale integral carryover.
  1. Simulate closed-loop vehicle dynamics: propagate ego state from the previous simulated state and accel_cmd, while treating recorded data only as exogenous inputs unless the task explicitly specifies replay semantics. If follow behavior must respond to controller changes, initialize from the measured gap if needed and propagate compatible ego/lead motion dynamically (for example via positions/gap) instead of mixing logged per-step ego outcomes or incompatible sampled gaps into the simulated plant.
  1. After each file write or major edit, immediately reopen the file and confirm the concrete implementation/content is present, complete, untruncated, and syntactically/import-valid before building on it; treat malformed content, escaped newlines, partial writes, suspicious truncation, placeholder prose, or summary-style write/edit descriptions as blocking errors.
  1. Tune PID parameters using measured simulation outcomes only after the closed-loop simulation is behaving plausibly, and verify that materially different gain sets produce different trajectories or metrics; if they do not, treat that as a blocking implementation bug. Inspect saved traces around cruise→follow transitions, emergency entry, and steady-state regions to distinguish tuning issues from state/update or command-arbitration bugs.
  1. Run the full required simulation/analysis pipeline and compute the task's stated metrics from complete artifacts, not partial console logs. For mixed driving regimes, map each metric to the operating regime and interval defined by the task (for example cruise-speed metrics during cruise-valid segments and spacing metrics during settled follow segments); if the spec instead requires whole-run evaluation, use that exactly.
  1. Keep evaluation logic, metric definitions, scenario assumptions, mode conditions, and interaction/tool-call protocol aligned with the task; if data meaning is ambiguous, validate the interpretation before changing plant or sensor semantics. Do not change metric definitions, masks, windows, detection logic, or simulation semantics just to obtain passing numbers.
  1. Before finishing, inspect the final deliverables directly and verify every required metric, safety bound, filename, row count, column order, runtime wiring, file/output requirement, and exact completion/output protocol from the produced artifacts themselves; if anything is unmet or unverified, continue iterating or report it explicitly as unresolved.
  1. If any required metric or safety check fails, treat the task as unfinished: keep iterating or state explicitly which requirement remains unmet; do not present the task as successful, complete, or "working" while known failures remain. Producing the requested files is not sufficient for completion, and you must not rationalize failed metrics as close enough, likely computed differently, or acceptable due to scenario difficulty. Emit any required completion token only when every required completion condition is satisfied.

Modes

Important Parameters

Tips

Validation and Spec Compliance

Validation and Spec Compliance

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.