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

references/vs-c-api.md

View on GitHub
# VS C API fallback (step-by-step integration via ctypes)

Use the VS C API only when a program requires direct step-by-step interaction
with the VehicleSim solver and Simulink co-simulation is not the desired
integration route.

For predefined inputs, use the CLI scenario runner. For Simulink-based runtime
feedback, use the verified Simulink route in `references/simulink-cosim.md`.

Status: **documented prototype, not verified end-to-end** — the prototypes below come from the VS_Commands_API memo and MATLAB-facing docs. Validate return-value semantics on a minimal scenario before relying on them.

## Loading

```python
import ctypes
dll = ctypes.WinDLL(r"<PROG>\Programs\solvers\carsim_64.dll",
                    winmode=0, use_last_error=True)
```

Dependent DLLs (road_64.dll, tire_64.dll, maux_64.dll, …) sit in the same directory and resolve automatically. On 64-bit Windows stdcall and cdecl share an ABI, so `WinDLL` vs `CDLL` is low-risk. The solver still needs a license (GUI or cslm.exe running).

List all exported symbols (300+) with the bundled tool:

```
python scripts/dump_dll_exports.py "<PROG>\Programs\solvers\carsim_64.dll"
```

## Documented flow (VS_Commands_API memo, simple_loop / path_follower)

```c
t = vs_setdef_and_read(simfile);   // build model + read all inputs; returns start time
vs_initialize();                   // compute initial conditions
dt = vs_get_tstep();
while (!stop) { /* write import arrays / read variables */ t = vs_integrate(t); }
                                   // or vs_integrate_io(t, imp_ptr, exp_ptr)
vs_terminate_run();                // write end files, clean up
vs_terminate();                    // release the model
```

## Function prototypes (confirm before production use)

| Function | Guessed prototype | Notes |
|---|---|---|
| `vs_setdef_and_read` | `double (const char*)` | arg = simfile or parsfile; returns start time |
| `vs_initialize` | `void ()` | |
| `vs_get_tstep` / `vs_get_time` | `double ()` | integration step / current time |
| `vs_get_var_id` | `int (const char*)` | name → id, −1 if unknown |
| `vs_get_var_ptr` | `double* (int)` | id → memory pointer; ctypes reads it directly (per-step sampling without ERD) |
| `vs_integrate` | `double (double, int*)` | MATLAB docs indicate it returns (t, stop) |
| `vs_integrate_io` | `double (double, double*, double*)` | step with import/export arrays |
| `vs_statement` | `int (const char*)` | inject one VS Command after read, before initialize (EQ_OUT/IMPORT/OUTPUT …) |
| `vs_error_occurred` | `int ()` | 0 = OK |
| `vs_get_error_message` | `int (char*, int)` | error text |
| `vs_terminate_run` / `vs_terminate` | `void ()` | end / release |
| `vs_run` | `int (const char*)` | whole-run (smoke-test comparison) |
| `vs_set_stop_run` | `void ()` | request early termination |

## If you go this route

1. Use a simfile backed by a GUI-expanded base (CSV outputs off when values are read through `vs_get_var_ptr`).
2. Confirm GUI/CSLM is running (license).
3. Validate on a minimal scenario first: check `vs_error_occurred()` after every stage, print `vs_get_output_message` / `vs_get_error_message` buffers, and compare one stepped trajectory against a `vs_run` of the same simfile.
4. Import semantics: import values are held over [k, k+1) (zero-order hold) — verify with wheel-speed increments before trusting closed-loop timing.
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