Skip to content

zyfgi/carsim-guide-skill

carsim-guide

Verified

Operate and automate CarSim simulations from an agent, including safe output and parameter discovery, named Run Control execution contexts, structured overrides, isolated batch sweeps, dataset dependency inspection, control-mode selection, result validation, diagnostics, and version-aware CLI/Simulink/VS API routing. Use for executing, configuring, exploring, or debugging CarSim. Do not use for vehicle-dynamics theory alone, generic dataframe work, or unrelated simulators.

FileKindSize
SKILL.mdskill md6.3 KB
examples/batches/friction_sweep.yamlconfig159 B
examples/batches/mass_friction_grid.yamlconfig198 B
examples/discovery/dataset_tree.pyscript693 B
examples/discovery/find_output.pyscript715 B
examples/discovery/find_parameter.pyscript761 B
examples/scenarios/basic_cruise.yamlconfig380 B
examples/scenarios/friction_change.yamlconfig379 B
examples/scenarios/steering_maneuver.yamlconfig377 B
examples/scenarios/tire_force_output.yamlconfig437 B
examples/scenarios/vehicle_override.yamlconfig376 B
examples/simulink_cosim.pyscript5.5 KB
examples/torque_vectoring.pyscript5.6 KB
references/advanced-controls.mdmarkdown4.0 KB
references/batch-workflows.mdmarkdown1.6 KB
references/compatibility.mdmarkdown1.4 KB
references/control-modes.mdmarkdown1.0 KB
references/database-exploration.mdmarkdown7.4 KB
references/dataset-syntax.mdmarkdown6.6 KB
references/outputs-and-units.mdmarkdown2.1 KB
references/parameter-discovery.mdmarkdown1.4 KB
references/parameters.mdmarkdown3.3 KB
references/python-interface.mdmarkdown7.9 KB
references/run-validation.mdmarkdown2.2 KB
references/scenarios.mdmarkdown3.3 KB
references/simulink-cosim.mdmarkdown4.0 KB
references/troubleshooting.mdmarkdown1.4 KB
references/version-compatibility.mdmarkdown811 B
references/vs-c-api.mdmarkdown3.3 KB
scripts/base_registry.pyscript4.7 KB
scripts/batch_runner.pyscript7.1 KB
scripts/carsim_batch.pyscript23.4 KB
scripts/carsim_errors.pyscript2.2 KB
scripts/control_modes.pyscript1.8 KB
scripts/cosim_model.mother4.7 KB
scripts/database_tools.pyscript16.5 KB
scripts/diagnose_run.pyscript444 B
scripts/diagnostics.pyscript6.9 KB
scripts/discovery_query.pyscript1.0 KB
scripts/dump_dll_exports.pyscript1.9 KB
scripts/output_registry.pyscript8.9 KB
scripts/override_registry.pyscript2.9 KB
scripts/parameter_discovery.pyscript8.6 KB
scripts/parameters.pyscript10.0 KB
scripts/result_contract.pyscript548 B
scripts/scenario_runner.pyscript11.3 KB
scripts/scenario_schema.pyscript4.0 KB
scripts/setup_paths.pyscript11.2 KB
scripts/tv_cosim.mother8.5 KB
scripts/validate_run.pyscript6.1 KB
scripts/version_compatibility.pyscript2.0 KB

scripts/base_registry.py

View on GitHub
"""Explicit GUI-expanded base bindings: name + SHA256, never newest-file.

A bound "base" is a GUI-expanded Run_all.par. It fixes more than the vehicle:
typically vehicle + procedure + controls + road context. Bindings live in a
machine-local JSON registry (never committed). Resolving re-verifies the
SHA256 and the CarSim version on every use; a changed base fails loudly
instead of silently switching vehicles.

Registry files may still contain a legacy top-level "vehicles" section (see
older registry formats); both shapes resolve.
"""
import argparse
import hashlib
import json
import re
from pathlib import Path

from carsim_errors import BaseResolutionError, VersionCompatibilityError
from version_compatibility import parse_version

_REQUIRED = ("base_run_all", "base_sha256", "carsim_version")


def sha256(path):
    digest = hashlib.sha256()
    with open(path, "rb") as stream:
        for block in iter(lambda: stream.read(1024 * 1024), b""):
            digest.update(block)
    return digest.hexdigest()


def product_version(prog, explicit=None):
    match = re.search(r"CarSim[ _-]?(\d{4}\.\d+)", str(prog), re.I)
    discovered = match.group(1) if match else None
    if explicit is not None and not re.fullmatch(r"\d{4}\.\d+", explicit):
        raise VersionCompatibilityError("CarSim version must look like 2024.0")
    if explicit and discovered and explicit != discovered:
        raise VersionCompatibilityError("Pinned CarSim version disagrees with install directory")
    if not (explicit or discovered):
        raise VersionCompatibilityError(
            "Cannot infer CarSim version; supply carsim_version explicitly")
    value = explicit or discovered
    parse_version(value)
    return value


def _load(registry_path):
    path = Path(registry_path)
    data = json.loads(path.read_text(encoding="utf-8")) if path.exists() else {}
    bases = data.get("bases")
    if bases is None:
        bases = data.get("vehicles", {})  # legacy vehicle-registry shape
    return path, data, bases


def bind_base(registry_path, name, base_run_all, carsim_version,
              run_control=None, vehicle=None, procedure=None, notes=None):
    """Bind <name> to one exact base file; refuses to overwrite a name."""
    path, data, bases = _load(registry_path)
    if name in bases or name in data.get("vehicles", {}):
        raise ValueError("Base name already bound; use a new name for a new base revision")
    base = Path(base_run_all).resolve(strict=True)
    product_version("", carsim_version)
    record = {"base_run_all": str(base), "base_sha256": sha256(base),
              "carsim_version": carsim_version}
    for key, value in (("run_control", run_control), ("vehicle", vehicle),
                       ("procedure", procedure), ("notes", notes)):
        if value:
            record[key] = value
    data.setdefault("bases", {})[name] = record
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
    return record


def resolve_base(registry_path, name, prog=None):
    """Resolve a bound base by name; re-verifies SHA256 and version."""
    _, _, bases = _load(registry_path)
    try:
        entry = dict(bases[name])
    except KeyError:
        raise BaseResolutionError(
            "Unknown base name %r; bind it explicitly first "
            "(python scripts/base_registry.py --registry ... --bind)" % name) from None
    missing = [key for key in _REQUIRED if key not in entry]
    if missing:
        raise BaseResolutionError("Base record %s is missing fields: %s" % (name, missing))
    base = Path(entry["base_run_all"])
    if not base.is_absolute():
        base = Path(registry_path).resolve().parent / base
    if sha256(base) != entry["base_sha256"]:
        raise BaseResolutionError("Base SHA256 mismatch for %s; bind a new name to "
                         "deliberately adopt the new revision" % name)
    product_version(prog, entry["carsim_version"])
    entry["base_run_all"] = str(base.resolve())
    entry["name"] = name
    return entry


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--registry", required=True)
    parser.add_argument("--name", required=True)
    parser.add_argument("--base", required=True, help="absolute Run_all.par path")
    parser.add_argument("--version", required=True, help="e.g. 2024.0")
    parser.add_argument("--run-control")
    parser.add_argument("--vehicle")
    parser.add_argument("--procedure")
    parser.add_argument("--notes")
    args = parser.parse_args()
    bind_base(args.registry, args.name, args.base, args.version,
              run_control=args.run_control, vehicle=args.vehicle,
              procedure=args.procedure, notes=args.notes)


if __name__ == "__main__":
    main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall