Control, physics, and traffic
Use this sub-skill for the three simulation components that close the motion
loop:
- Controller: planar dynamic-bicycle vehicle state, linear/nonlinear MPC,
trajectory tracking, and the controller gRPC session.
- Physics: Warp ground-mesh intersection that corrects vehicle/object poses;
it is not a collision engine or a replacement for vehicle dynamics.
- Traffic: the CATK-backed traffic gRPC service, including session history,
logged replay, handover, prediction batching, and failure statuses.
Do not use this sub-skill to compose a wizard deployment, choose a driver policy,
or edit protobufs. Route those to simulation-wizard, drivers-and-plugins, or
grpc-and-developer-tools, respectively. Use runtime-services for the
runtime's event loop and service orchestration, and evaluation-and-logs for
post-run logs and metrics.
Start with a capability and backend check
Identify the service being changed or queried. Record the simulation time
unit, coordinate frame, scene identifier, and whether the request is replay
or closed-loop inference.
Run the bundled, read-only probe before debugging imports or optional
backends:
Read backend compatibility, then run
the bundled backend checker before debugging
imports or optional backends:
python scripts/check_backend.py
python scripts/check_backend.py --usdz-folder /data/scenes \
--model-config /models/catk/config.yaml \
--checkpoint /models/catk/latest.ckpt \
--token-dir /models/tokens
The second form only inspects supplied paths; it never downloads or changes
them. Treat warnings about CUDA, PyG extensions, USDZ, or model assets as
capability limits, not as proof of a working CATK service.
For a controller-only CPU smoke test, use the package's focused tests or
instantiate LinearMPC with an 8-element state and a time-stamped
Trajectory. For a nonlinear smoke test, ensure do_mpc and CasADi are
importable before the first compute_control call.
For physics, use a small valid PLY ground mesh and positive AABB dimensions.
PhysicsBackend constructs Warp mesh data and launches CUDA kernels during
update_pose; a successful Python import is not a physics execution test.
For CATK, verify the scene directory contains .usdz files and that the
model config, checkpoint, token directory, CUDA device, and matching PyG
compiled extensions are all available. Never substitute a static traffic
trajectory for a failed post-handover prediction.
See backend compatibility before
installing optional packages and troubleshooting
when a check fails.
Choose and use the controller
- Represent the current vehicle state in the documented order
[x, y, yaw, vx_cg, vy_cg, yaw_rate, steering, accel]. The position and yaw
are for the rig origin in the temporary inertial frame; vx_cg and vy_cg
are body-frame CG velocities. Do not silently treat rig-frame lateral speed
as CG lateral speed.
- Use linear MPC (
mpc_implementation: linear) as the normal fast choice.
It linearizes the bicycle model about the current state and solves an OSQP
QP. Use nonlinear MPC for aggressive maneuvers or tight turns when the
slower do_mpc/CasADi/IPOPT solve is acceptable. This is a modeling trade-off,
not a claim that nonlinear is always more stable.
- Keep
n_horizon and dt_mpc consistent with the trajectory sampling. The
defaults are 20 steps and 0.1 seconds. Tracking cost begins at
gains.idx_start_penalty (default 10), while actuator regularization applies
to command changes.
- In a service session, call
start_session before the first run, provide a
non-empty planned trajectory, advance to a strictly later future_time_us,
and close the session exactly once. The first run lazily constructs the
system and creates a CSV controller log.
- Set
coerce_dynamic_state when current ground-truth dynamic state should
replace the model's velocity, yaw rate, and acceleration before solving. The
system converts rig-frame velocity to CG-frame velocity and preserves the
integrated pose origin.
The exact dataclasses, solver bounds, frame conversion, service invariants, and
standalone server flags are in controller API.
Apply ground constraints
Give the physics service a scene artifact glob ending in .usdz and select
a scene whose ground mesh is available. The command shape is:
physics_server --artifact-glob '/data/artifacts/*.usdz' \
--host 0.0.0.0 --port 8080 --cache-size 16
--use-ground-mesh, --visualize, and the cache size affect artifact/backend
loading; visualization is optional and may require extra packages.
For every pose, physics samples the bottom of the AABB, casts ±Z rays into
the Warp mesh, fits a plane, and applies bounded translation/rotation
corrections. It deliberately preserves predicted X/Y after correction and
returns a status for each pose.
Handle SUCCESSFUL_UPDATE, INSUFFICIENT_POINTS_FITPLANE, HIGH_TRANSLATION,
and HIGH_ROTATION as distinct observations. Repeated high corrections are
usually a scene, AABB, timestamp, or upstream pose problem; do not hide them
by retrying indefinitely.
Physics does not model collisions, full vehicle dynamics, or arbitrary lateral
motion. See physics and traffic.
Run a CATK traffic session
Start the service only after its Hydra config resolves. A documented local
shape is:
catk_trafficsim_server \
--config-path=/path/to/config-dir \
--config-name=server.yaml \
server.port=6200 \
catk.loader.usdz_folder=/data/scenes
The model paths and timing settings belong in the resolved config. The
wizard normally writes this config for a container deployment; do not make a
second deployment recipe here.
start_session requires a session UUID, scene ID, at least one logged object
trajectory including EGO, and a positive handover_time_us. The service
builds a fixed history window (num_history_steps, default 16) sampled at
time_step (default 0.1 s).
At or before handover, simulate resamples logged trajectories and returns
replay. After handover, it resamples the latest history, fills the ego future
from the request/update, runs CATK, and merges predicted agent trajectories.
Requests are serialized per session but different sessions may reach the
inference batcher concurrently.
Respect the configured prediction_steps (default 5). A request beyond the
fixed prediction horizon is INVALID_ARGUMENT; missing usable map/model
predictions after handover are FAILED_PRECONDITION. An unexpected model
exception is INTERNAL. These statuses are actionable distinctions.
Close sessions and retry only after fixing the reported scene, trajectory,
horizon, map, model, or backend issue. There is no valid CPU/static fallback
for CATK's required post-handover prediction path.
Use physics and traffic for the request
sequence, config fields, batching semantics, and status mapping.
Verification and handoff
- Run parser/help checks for the bundled script and server commands without
starting a daemon or downloading assets.
- Run controller system, linear-MPC, nonlinear-MPC, physics-utils, and traffic
service/batching tests according to their backend markers. Keep CATK
integration tests skipped unless CUDA, matching PyG extensions, USDZ scenes,
and model weights are all present.
- Test the difficult cases in the review artifact: aggressive-turn controller
selection and a CATK
FAILED_PRECONDITION after handover. The expected answer
must name the validation signal and must not invent a fallback.
- If a service contract or protobuf message is the issue, hand off rather than
duplicating generic message definitions. Record unresolved backend/data gaps
explicitly in the verification report.
1---2name: control-physics-traffic3description: "Use when an AlpaSim task concerns vehicle state, controller or MPC4 selection, ground-mesh physics, CATK traffic sessions, handover behavior, or5 backend/data requirements for these services."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/control-physics-traffic9 disco-role: operating10license: Apache 2.011---1213# Control, physics, and traffic1415Use this sub-skill for the three simulation components that close the motion16loop:1718- **Controller:** planar dynamic-bicycle vehicle state, linear/nonlinear MPC,19 trajectory tracking, and the controller gRPC session.20- **Physics:** Warp ground-mesh intersection that corrects vehicle/object poses;21 it is not a collision engine or a replacement for vehicle dynamics.22- **Traffic:** the CATK-backed traffic gRPC service, including session history,23 logged replay, handover, prediction batching, and failure statuses.2425Do not use this sub-skill to compose a wizard deployment, choose a driver policy,26or edit protobufs. Route those to `simulation-wizard`, `drivers-and-plugins`, or27`grpc-and-developer-tools`, respectively. Use `runtime-services` for the28runtime's event loop and service orchestration, and `evaluation-and-logs` for29post-run logs and metrics.3031## Start with a capability and backend check32331. Identify the service being changed or queried. Record the simulation time34 unit, coordinate frame, scene identifier, and whether the request is replay35 or closed-loop inference.362. Run the bundled, read-only probe before debugging imports or optional37 backends:3839 Read [backend compatibility](references/backend-compatibility.md), then run40 the bundled [backend checker](scripts/check_backend.py) before debugging41 imports or optional backends:4243 ```bash44 python scripts/check_backend.py45 python scripts/check_backend.py --usdz-folder /data/scenes \46 --model-config /models/catk/config.yaml \47 --checkpoint /models/catk/latest.ckpt \48 --token-dir /models/tokens49 ```5051 The second form only inspects supplied paths; it never downloads or changes52 them. Treat warnings about CUDA, PyG extensions, USDZ, or model assets as53 capability limits, not as proof of a working CATK service.543. For a controller-only CPU smoke test, use the package's focused tests or55 instantiate `LinearMPC` with an 8-element state and a time-stamped56 `Trajectory`. For a nonlinear smoke test, ensure `do_mpc` and CasADi are57 importable before the first `compute_control` call.584. For physics, use a small valid PLY ground mesh and positive AABB dimensions.59 `PhysicsBackend` constructs Warp mesh data and launches CUDA kernels during60 `update_pose`; a successful Python import is not a physics execution test.615. For CATK, verify the scene directory contains `.usdz` files and that the62 model config, checkpoint, token directory, CUDA device, and matching PyG63 compiled extensions are all available. Never substitute a static traffic64 trajectory for a failed post-handover prediction.6566See [backend compatibility](references/backend-compatibility.md) before67installing optional packages and [troubleshooting](references/troubleshooting.md)68when a check fails.6970## Choose and use the controller71721. Represent the current vehicle state in the documented order73 `[x, y, yaw, vx_cg, vy_cg, yaw_rate, steering, accel]`. The position and yaw74 are for the rig origin in the temporary inertial frame; `vx_cg` and `vy_cg`75 are body-frame CG velocities. Do not silently treat rig-frame lateral speed76 as CG lateral speed.772. Use **linear MPC** (`mpc_implementation: linear`) as the normal fast choice.78 It linearizes the bicycle model about the current state and solves an OSQP79 QP. Use **nonlinear MPC** for aggressive maneuvers or tight turns when the80 slower do_mpc/CasADi/IPOPT solve is acceptable. This is a modeling trade-off,81 not a claim that nonlinear is always more stable.823. Keep `n_horizon` and `dt_mpc` consistent with the trajectory sampling. The83 defaults are 20 steps and 0.1 seconds. Tracking cost begins at84 `gains.idx_start_penalty` (default 10), while actuator regularization applies85 to command changes.864. In a service session, call `start_session` before the first run, provide a87 non-empty planned trajectory, advance to a strictly later `future_time_us`,88 and close the session exactly once. The first run lazily constructs the89 system and creates a CSV controller log.905. Set `coerce_dynamic_state` when current ground-truth dynamic state should91 replace the model's velocity, yaw rate, and acceleration before solving. The92 system converts rig-frame velocity to CG-frame velocity and preserves the93 integrated pose origin.9495The exact dataclasses, solver bounds, frame conversion, service invariants, and96standalone server flags are in [controller API](references/controller-api.md).9798## Apply ground constraints991001. Give the physics service a scene artifact glob ending in `.usdz` and select101 a scene whose ground mesh is available. The command shape is:102103 ```bash104 physics_server --artifact-glob '/data/artifacts/*.usdz' \105 --host 0.0.0.0 --port 8080 --cache-size 16106 ```107108 `--use-ground-mesh`, `--visualize`, and the cache size affect artifact/backend109 loading; visualization is optional and may require extra packages.1102. For every pose, physics samples the bottom of the AABB, casts ±Z rays into111 the Warp mesh, fits a plane, and applies bounded translation/rotation112 corrections. It deliberately preserves predicted X/Y after correction and113 returns a status for each pose.1143. Handle `SUCCESSFUL_UPDATE`, `INSUFFICIENT_POINTS_FITPLANE`, `HIGH_TRANSLATION`,115 and `HIGH_ROTATION` as distinct observations. Repeated high corrections are116 usually a scene, AABB, timestamp, or upstream pose problem; do not hide them117 by retrying indefinitely.118119Physics does not model collisions, full vehicle dynamics, or arbitrary lateral120motion. See [physics and traffic](references/physics-and-traffic.md).121122## Run a CATK traffic session1231241. Start the service only after its Hydra config resolves. A documented local125 shape is:126127 ```bash128 catk_trafficsim_server \129 --config-path=/path/to/config-dir \130 --config-name=server.yaml \131 server.port=6200 \132 catk.loader.usdz_folder=/data/scenes133 ```134135 The model paths and timing settings belong in the resolved config. The136 wizard normally writes this config for a container deployment; do not make a137 second deployment recipe here.1382. `start_session` requires a session UUID, scene ID, at least one logged object139 trajectory including `EGO`, and a positive `handover_time_us`. The service140 builds a fixed history window (`num_history_steps`, default 16) sampled at141 `time_step` (default 0.1 s).1423. At or before handover, `simulate` resamples logged trajectories and returns143 replay. After handover, it resamples the latest history, fills the ego future144 from the request/update, runs CATK, and merges predicted agent trajectories.145 Requests are serialized per session but different sessions may reach the146 inference batcher concurrently.1474. Respect the configured `prediction_steps` (default 5). A request beyond the148 fixed prediction horizon is `INVALID_ARGUMENT`; missing usable map/model149 predictions after handover are `FAILED_PRECONDITION`. An unexpected model150 exception is `INTERNAL`. These statuses are actionable distinctions.1515. Close sessions and retry only after fixing the reported scene, trajectory,152 horizon, map, model, or backend issue. There is no valid CPU/static fallback153 for CATK's required post-handover prediction path.154155Use [physics and traffic](references/physics-and-traffic.md) for the request156sequence, config fields, batching semantics, and status mapping.157158## Verification and handoff159160- Run parser/help checks for the bundled script and server commands without161 starting a daemon or downloading assets.162- Run controller system, linear-MPC, nonlinear-MPC, physics-utils, and traffic163 service/batching tests according to their backend markers. Keep CATK164 integration tests skipped unless CUDA, matching PyG extensions, USDZ scenes,165 and model weights are all present.166- Test the difficult cases in the review artifact: aggressive-turn controller167 selection and a CATK `FAILED_PRECONDITION` after handover. The expected answer168 must name the validation signal and must not invent a fallback.169- If a service contract or protobuf message is the issue, hand off rather than170 duplicating generic message definitions. Record unresolved backend/data gaps171 explicitly in the verification report.