zrwangems/dsh-zrwang-plugin / skills/engineering/matlab/automotive/roadrunner-scenario-authoring
roadrunner-scenario-authoring
VerifiedProgrammatically author RoadRunner scenarios from MATLAB using roadrunnerAPI. Use when adding actors, creating routes, building scenario logic (phases, conditions, actions), placing vehicles/pedestrians, defining cut-in/crossing/ follow scenarios, or any programmatic scenario creation in RoadRunner. Triggers on: roadrunnerAPI, scenario authoring, add actor, create route, phase logic, cut-in scenario, pedestrian crossing, scenario from MATLAB.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 26.5 KB |
| manifest.yaml | config | 540 B |
| references/actions-and-conditions.md | markdown | 11.6 KB |
| references/asset-catalog.md | markdown | 4.2 KB |
| references/collision-utility.md | markdown | 3.2 KB |
| references/lane-connectivity.md | markdown | 4.5 KB |
| references/physics-first-design.md | markdown | 6.2 KB |
| references/routes-and-points.md | markdown | 6.7 KB |
| references/scenario-templates.md | markdown | 16.4 KB |
| references/scene-awareness.md | markdown | 5.0 KB |
| scripts/helperAnalyzeHDMapLanes.m | other | 7.5 KB |
| scripts/helperClassifyRoadFeatures.m | other | 15.3 KB |
| scripts/helperGetPositionFromHDMap.m | other | 6.5 KB |
| scripts/helperPlaceActors.m | other | 5.8 KB |
| scripts/helperSceneAwareness.m | other | 11.3 KB |
| scripts/helperSurveyLanes.m | other | 3.0 KB |
scripts/helperPlaceActors.m
View on GitHubfunction [actors, placementReport] = helperPlaceActors(rrs, rrprj, phaseLogic, rrHDMap, actorSpecs)
%helperPlaceActors Batch place, anchor, and verify multiple actors.
%
% [actors, report] = helperPlaceActors(rrs, rrprj, phaseLogic, rrHDMap, actorSpecs)
%
% actorSpecs is a struct array with fields:
% .Name - string (e.g., "Ego")
% .AssetPath - string (e.g., "Vehicles/Sedan.fbx")
% .AssetType - string ("VehicleAsset" or "CharacterAsset")
% .LaneIndex - integer (rank by length, 1=longest within filter)
% .Fraction - double [0,1] (position along lane)
% .Speed - double (m/s)
% Optional fields:
% .TravelDirection - string (default "Forward")
% .LateralOffset - double in meters (default 0)
% .FilterLaneIDs - string array of lane IDs to restrict placement to
%
% Returns:
% actors - cell array of actor handles
% placementReport - struct with .AllValid, .Details, .Summary
%
% This is a helper function for example purposes and may be removed or
% modified in the future.
arguments
rrs
rrprj
phaseLogic
rrHDMap
actorSpecs (1,:) struct
end
% Ensure sibling helper scripts are on path
if ~exist('helperGetPositionFromHDMap', 'file')
addpath(fileparts(mfilename('fullpath')));
end
numActors = numel(actorSpecs);
actors = cell(1, numActors);
details = struct('Name', {}, 'Position', {}, 'Status', {}, 'Message', {});
assetCache = containers.Map('KeyType', 'char', 'ValueType', 'any');
allValid = true;
for i = 1:numActors
spec = actorSpecs(i);
% Defaults for optional fields
if ~isfield(spec, 'TravelDirection') || isempty(spec.TravelDirection)
spec.TravelDirection = "Forward";
end
if ~isfield(spec, 'LateralOffset') || isempty(spec.LateralOffset)
spec.LateralOffset = 0;
end
if ~isfield(spec, 'FilterLaneIDs')
spec.FilterLaneIDs = "";
end
detail.Name = spec.Name;
detail.Position = [0, 0, 0];
detail.Status = "FAIL";
detail.Message = "";
try
% Get position from HD Map (with optional lane ID filter)
laneIDArgs = {};
filterIDs = string(spec.FilterLaneIDs);
filterIDs = filterIDs(filterIDs ~= "");
if ~isempty(filterIDs)
laneIDArgs = {"LaneIDs", filterIDs};
end
[position, ~] = helperGetPositionFromHDMap(rrHDMap, ...
spec.LaneIndex, spec.Fraction, ...
"TravelDirection", spec.TravelDirection, ...
"LaneType", "Driving", ...
"Offset", spec.LateralOffset, ...
"MinLength", 10, ...
laneIDArgs{:});
% Get or cache asset
assetKey = char(spec.AssetPath + "|" + spec.AssetType);
if assetCache.isKey(assetKey)
asset = assetCache(assetKey);
else
asset = getAsset(rrprj, spec.AssetPath, spec.AssetType);
assetCache(assetKey) = asset;
end
% Place actor and anchor
actor = addActor(rrs, asset, position);
actor.Name = spec.Name;
autoAnchor(actor.InitialPoint);
% Set initial speed
initPhase = initialPhaseForActor(phaseLogic, actor);
initPhase.Actions(1).Speed = spec.Speed;
% Verify placement — WorldPosition must not be [0,0,0]
worldPos = actor.InitialPoint.WorldPosition;
if norm(worldPos(1:2)) < 0.01
detail.Status = "FAIL";
detail.Message = "autoAnchor failed — WorldPosition is [0,0,0].";
allValid = false;
else
detail.Status = "OK";
detail.Message = "Placed and verified.";
end
detail.Position = worldPos;
actors{i} = actor;
catch ME
detail.Status = "FAIL";
detail.Message = sprintf("Error: %s", ME.message);
allValid = false;
actors{i} = [];
end
details(end+1) = detail; %#ok<AGROW>
end
%% Check for bounding box overlaps between placed actors
minSeparation = 6.0; % meters (sedan ~4.7m + 1.3m buffer)
overlapWarnings = strings(0, 1);
for i = 1:numActors
if isempty(details(i).Position) || all(details(i).Position == 0)
continue;
end
for j = (i+1):numActors
if isempty(details(j).Position) || all(details(j).Position == 0)
continue;
end
dist = norm(details(i).Position - details(j).Position);
if dist < minSeparation
overlapWarnings(end+1) = sprintf( ...
"WARNING: %s and %s are %.1fm apart (min safe: %.1fm) — bounding boxes may overlap", ...
details(i).Name, details(j).Name, dist, minSeparation); %#ok<AGROW>
allValid = false;
details(i).Status = "OVERLAP";
details(j).Status = "OVERLAP";
end
end
end
%% Build report
placementReport.AllValid = allValid;
placementReport.Details = details;
lines = strings(0, 1);
lines(end+1) = sprintf("Placement: %d actors, AllValid=%s", numActors, string(allValid));
for i = 1:numel(details)
d = details(i);
lines(end+1) = sprintf(" [%s] %s: [%.1f,%.1f,%.1f] %s", ...
d.Status, d.Name, d.Position(1), d.Position(2), d.Position(3), d.Message); %#ok<AGROW>
end
for w = 1:numel(overlapWarnings)
lines(end+1) = overlapWarnings(w); %#ok<AGROW>
end
placementReport.Summary = strjoin(lines, newline);
fprintf("%s\n", placementReport.Summary);
end
% Copyright 2026 The MathWorks, Inc.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |