matlab/matlab-agentic-toolkit / skills-catalog/automotive/roadrunner-rrhd-authoring
roadrunner-rrhd-authoring
VerifiedBuild RoadRunner HD Map entities in MATLAB — lanes, boundaries, markings, junctions, signs, signals, barriers, parking. Use when creating driving scenes from scratch, authoring road networks for simulation and testing automated driving systems, or assembling RRHD maps from Lanelet2 or other HD map sources.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 23.3 KB |
| manifest.yaml | config | 620 B |
| references/alignmentRules.md | markdown | 9.8 KB |
| references/apiReference.md | markdown | 8.5 KB |
| references/deduplicateBoundaries.md | markdown | 4.9 KB |
| references/junctionPolygon.md | markdown | 6.6 KB |
| references/leftGapFilter.md | markdown | 6.5 KB |
| references/orthogonalSplit.md | markdown | 7.7 KB |
| references/resolveHeights.md | markdown | 6.0 KB |
| references/snapEndpoints.md | markdown | 3.9 KB |
| references/splitClosedGeometry.md | markdown | 3.7 KB |
| references/synthesizeCenterLine.md | markdown | 4.6 KB |
| references/validateMap.md | markdown | 1.1 KB |
| scripts/detectAlignment.m | other | 3.1 KB |
| scripts/resolveHeightConflicts.m | other | 5.8 KB |
| scripts/snapConnectedEndpoints.m | other | 3.9 KB |
| scripts/validateRRHD.m | other | 6.3 KB |
references/splitClosedGeometry.md
View on GitHub# Skill: splitClosedGeometry
**Package:** `rrhd_authoring.utils`
**Function:** `[ptsA, ptsB, wasSplit] = rrhd_authoring.utils.splitClosedGeometry(pts, Tolerance=1.0)`
**Source:** `+rrhd_authoring/+utils/splitClosedGeometry.m`
## Description
Detects closed-loop geometry (start point ≈ end point) and splits at the midpoint into two open segments. **RoadRunner cannot render self-closed roads** — this is a required workaround.
## Inputs
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `pts` | Nx3 double | (required) | [x y z] coordinates |
| `Tolerance` | double | `1.0` | Max distance (meters) between first/last point to consider closed |
## Outputs
- `ptsA` — first half (points 1..mid). If not closed, returns original `pts`
- `ptsB` — second half (points mid..end), shares start with ptsA's end. If not closed, returns `[]`
- `wasSplit` — logical, true if geometry was closed and split
## Algorithm
```matlab
isClosed = (n >= 4) && (norm(pts(1,:) - pts(end,:)) < tol);
if ~isClosed, return pts unchanged; end
ptsOpen = pts(1:end-1, :); % remove closing duplicate
mid = ceil(nOpen / 2);
ptsA = ptsOpen(1:mid, :);
ptsB = ptsOpen(mid:end, :); % overlap at split point
```
## Example
```matlab
pts = [0 0 0; 10 0 0; 10 10 0; 0 10 0; 0 0 0]; % closed square
[A, B, split] = rrhd_authoring.utils.splitClosedGeometry(pts);
% split = true, A = [0 0 0; 10 0 0], B = [10 0 0; 10 10 0; 0 10 0]
```
## Closed-Loop Boundary Handling (pre-requisite for center line synthesis)
When BOTH left and right boundaries are closed loops, standard direction detection (`dot(leftOverall, rightOverall)`) fails because the overall direction vector is near-zero. This causes incorrect flips that produce center lines cutting across the track interior.
**Detection:** A boundary is a closed loop if `norm(geom(1,:) - geom(end,:)) < 1.0m`.
**MANDATORY: Handle closed-loop boundaries BEFORE direction detection:**
```matlab
leftOverall = leftGeom(end,:) - leftGeom(1,:);
rightOverall = rightGeom(end,:) - rightGeom(1,:);
% Closed-loop detection: use LOCAL direction instead of overall
if norm(leftOverall(1:2)) < 1.0 || norm(rightOverall(1:2)) < 1.0
% Use direction of first few segments
lDir = leftGeom(min(5,size(leftGeom,1)),:) - leftGeom(1,:);
% Find closest point on right boundary to left start
dists = vecnorm(rightGeom(:,1:2) - leftGeom(1,1:2), 2, 2);
[~, rStart] = min(dists);
rEnd = min(rStart+4, size(rightGeom,1));
rDir = rightGeom(rEnd,:) - rightGeom(rStart,:);
needFlip = dot(lDir(1:2), rDir(1:2)) < 0;
else
% Standard: use overall direction
needFlip = dot(leftOverall(1:2), rightOverall(1:2)) < 0;
end
if needFlip, rightGeom = flipud(rightGeom); end
% For closed-loop boundaries, align start points (rotate right to match left)
leftStartGap = norm(leftGeom(1,1:2) - leftGeom(end,1:2));
rightStartGap = norm(rightGeom(1,1:2) - rightGeom(end,1:2));
if leftStartGap < 1.0 && rightStartGap < 1.0
dists = vecnorm(rightGeom(:,1:2) - leftGeom(1,1:2), 2, 2);
[~, rStart] = min(dists);
if rStart > 1
rightGeom = [rightGeom(rStart:end,:); rightGeom(2:rStart,:)];
end
end
```
**Why start-point alignment?** Closed-loop boundaries have no natural "start". If left boundary starts at the north end of the oval and right boundary starts at the south end, averaging them produces a center line that zigzags. Rotating the right boundary so its start is closest to the left boundary's start ensures point-by-point averaging produces a valid center line.
**After handling closed loops:** Skip orthogonal endpoint enforcement for closed-loop center lines (`norm(centerGeom(1,:) - centerGeom(end,:)) < 1.0`) since there are no meaningful endpoints.
----
Copyright 2026 The MathWorks, Inc.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |