Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/automotive/matlab-use-scenario-builder

matlab-use-scenario-builder

Verified

Generate driving scenes, scenarios, road surfaces, and 3D content from scenariobuilder.* sensor data (GPS, camera, lidar, actor tracks) using Scenario Builder for Automated Driving Toolbox. BUILD, EXPORT, or AUGMENT a virtual scenario/scene/map: ego or actor trajectories, trajectory smoothing, OpenCRG road-surface extraction, 3D asset generation, static-object placement, point-cloud georeferencing + elevation, lane-based ego localization, sensor-fusion tracking, scenario-event extraction (cut-ins, hard brakes, near-misses, ADAS disengagements), or export to RoadRunner, drivingScenario, OpenDRIVE, OpenCRG, OpenSCENARIO, or Unreal Engine. Also: log-to-scenario, scenario harvesting, accident/near-miss reconstruction, SOTIF (ISO 21448) and ISO 26262 scenario coverage, USGS-aerial-lidar augmentation, traffic-sign placement, vision-based vehicle classification for actor assets. NOT for raw-data import or multi-sensor sync/crop/offset/timestamp normalization — route those to matlab-import-driving-data.

FileKindSize
SKILL.mdskill md56.6 KB
manifest.yamlconfig704 B
references/actortrackdata-api.mdmarkdown3.3 KB
references/example-roadrunner-scenario.mdmarkdown4.3 KB
references/example-scenario-from-gps-and-tracks.mdmarkdown9.6 KB
references/execution-rules-detail.mdmarkdown16.7 KB
references/gpsdata-api.mdmarkdown2.4 KB
references/osm-flat-scene-gotchas.mdmarkdown8.8 KB
references/per-frame-detections-to-actortrackdata.mdmarkdown7.8 KB
references/python-spkg-install-troubleshooting.mdmarkdown5.8 KB
references/trajectory-api.mdmarkdown13.7 KB
references/visualization-patterns.mdmarkdown12.4 KB
references/workflow-04-roadrunner-export-detail.mdmarkdown32.6 KB
references/workflow-07-height-correction.mdmarkdown3.3 KB
references/workflow-08-lane-localization.mdmarkdown39.1 KB
references/workflow-09-static-objects.mdmarkdown9.3 KB
references/workflow-10-road-surface-opencrg.mdmarkdown4.7 KB
references/workflow-11-point-cloud-georef.mdmarkdown4.5 KB
references/workflow-12-3d-asset-generation.mdmarkdown2.0 KB
references/workflow-13-event-extraction.mdmarkdown5.3 KB
references/workflow-14-sensor-fusion-tracking.mdmarkdown6.9 KB
references/workflow-15-driving-scenario-designer.mdmarkdown7.6 KB
references/workflow-16-aerial-lidar-augmentation.mdmarkdown14.4 KB
references/workflow-17-traffic-signs-from-sensor-data.mdmarkdown12.5 KB
references/workflow-18-vehicle-classification.mdmarkdown12.8 KB
references/workflow-19-ego-lane-inference.mdmarkdown10.0 KB
scripts/buildBestCropGrid.mother5.2 KB
scripts/openFile.mother716 B
scripts/plotActorCircles.mother3.5 KB
scripts/plotBEVAndCamera.mother4.2 KB

references/workflow-11-point-cloud-georef.md

View on GitHub
---
name: workflow-11-point-cloud-georef
description: Add elevation to flat HD maps from georeferenced point clouds (addElevation), choose between addElevation and roadSurface based on simulator capability, extract per-frame ego-centric point clouds via egoPointCloudExtractor, and georeference raw lidar sequences. Loaded when user mentions point cloud georeferencing, elevation, or per-frame lidar extraction.
---

# Workflow 11 — Point Cloud Georeferencing & Elevation Pipeline

> **Parent skill:** [`SKILL.md`](../SKILL.md) — Loaded when user has georeferenced point clouds and needs elevation, lidar slicing, or stitching.
>
> **Related references:** [`workflow-10-road-surface-opencrg.md`](workflow-10-road-surface-opencrg.md) for the alternate `roadSurface` → OpenCRG path when the target simulator doesn't support 3D boundary points.

Use `addElevation` and `egoPointCloudExtractor` to work with georeferenced point clouds in the scenario pipeline.

## Choosing Between `addElevation` and `roadSurface` (OpenCRG)
| Use Case | Function | Why |
|----------|----------|-----|
| Simulator supports 3D boundary points (e.g., RoadRunner, Unreal) | `addElevation` | Adds Z directly to road/lane geometry |
| Simulator does NOT support 3D boundaries (e.g., IPG CarMaker) | `roadSurface` → `exportToASAMOpenCRG` | Encodes elevation/banking as OpenCRG surface; import OpenDRIVE + OpenCRG together to simulate banking |

> **Key insight:** Some simulators like CarMaker cannot represent banking through 3D boundary points. For these, create an ASAM OpenCRG file using `roadSurface` and pair it with the OpenDRIVE road network. The CRG encodes the road profile (elevation, cross-slope, banking) that the simulator applies on top of the flat road geometry.

## Adding Elevation to HD Maps
When you have a georeferenced point cloud (from aerial lidar, SLAM stitching, or USGS 3DEP data), add real-world elevation to flat HD maps:
```matlab
%% Add elevation to roadrunnerHDMap using georeferenced point cloud
% rrMap: flat HD map from OSM (z=0 everywhere)
% geoRefPtCloud: georeferenced pointCloud with real elevation
elevatedMap = addElevation(rrMap, geoRefPtCloud, GridStep=0.01);
write(elevatedMap, fullfile(tempdir, "elevated_roads.rrhd"));
```

**`GridStep` parameter** (default: `0.01` meters = 1cm):
- Controls the interpolation grid resolution when sampling elevation from the point cloud
- **Lower values** → higher elevation accuracy, but significantly longer processing time
- **Higher values** → faster processing, but may miss fine elevation detail
- Recommended: start with `0.05` (5cm) for quick validation, then reduce to `0.01` or lower for final output

`addElevation` also works on:
- **2D lane boundary points** (N×2 → N×3): adds Z to flat lane geometry
- **Static object cuboids** (M×9): adjusts Z position to sit on terrain

## Extracting Per-Frame Point Clouds Along Ego Path
Use `egoPointCloudExtractor` to slice a large merged point cloud into per-frame local views along the ego trajectory — useful for generating synthetic lidar data or transforming to model-input format:
```matlab
%% Extract ego-centric point cloud frames from a large merged map
pcExtractor = egoPointCloudExtractor(mergedPtCloud, egoTrajectory, ...
    MaxRange=80, Height=1.8);

fprintf("Frames available: %d\n", pcExtractor.NumPointClouds);

% Extract frame-by-frame (ego-relative coordinates)
frameIdx = 1;
while hasFrame(pcExtractor)
    localPC = extractFrame(pcExtractor);
    % localPC is in ego-relative coordinates
    % Use pctransform to convert to sensor frame if needed
    frameIdx = frameIdx + 1;
end
```

## Georeferencing Workflow (from raw lidar sequences)
This section is for **vehicle-mounted lidar sequences** that need register + stitch + georeference. For **aerial top-down lidar** (a single LAS/LAZ tile with embedded CRS or a known EPSG code), use [`workflow-16-aerial-lidar-augmentation.md`](workflow-16-aerial-lidar-augmentation.md) — it goes through `readCRS` + `helperGeoreferencePointCloud` and pairs the result with OSM at the same georeference. Do NOT try to register an already-stitched aerial tile.

To build a georeferenced point cloud from a sequence of lidar frames + GPS:
1. **Register** frames using `pcregistericp` or `pcregisterndt`
2. **Stitch** into merged cloud using `pcmerge` / `pctransform`
3. **Georeference** using GPS coordinates (align local frame to lat/lon via `LocalOrigin`)
4. **Use** the georeferenced cloud with `addElevation`, `roadSurface`, or `egoPointCloudExtractor`

----

Copyright 2026 The MathWorks, Inc.

----
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall