create-scenario
하는 일
이 스킬은 CARLA 시뮬레이터용 새 주행 테스트 시나리오를 작성합니다. 액터, 행동, 통과 기준을 포함합니다. 자율주행 소프트웨어용 맞춤 테스트를 만드는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓차가 특정 도로 상황을 처리해야 하는 새 테스트를 만들고 싶을 때.
- ✓테스트 러너가 이름으로 찾아 실행할 수 있는 시나리오 파일이 필요할 때.
- ✓시뮬레이터에서 실행하기 전에 새 시나리오의 오류를 확인하고 싶을 때.
스킬 링크
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/scenario-runner/create-scenario/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“다른 차가 갑자기 내 차 앞으로 끼어드는 새 CARLA 테스트를 작성하고, 제대로 로드되는지 확인해 줄 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 필요한 구조를 갖춘 시작 파일을 만들고, 액터, 행동, 검사를 채운 뒤, 빠른 오프라인 검사를 실행합니다. 파일 이름은 시나리오 이름과 같아야 하며, 그렇지 않으면 테스트 러너가 찾지 못합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Create a scenario
Paths.
scripts/…andreferences/…below are relative to the directory holding this SKILL.md. Your working directory is the user's project, not that directory, so prefix them with its absolute path or the command is not found.
A scenario is two files:
srunner/scenarios/my_scenario.py the class: actors + behaviour tree + criteria
srunner/examples/MyScenario.xml the config: town, ego spawn, parameters
ScenarioRunner finds the class by globbing $SCENARIO_RUNNER_ROOT/srunner/scenarios/*.py
and matching the config's type attribute against class names in those modules.
There is no registration list — dropping the two files in is the whole
install. The corollary is that the type in the XML must match the class name
exactly, and a typo produces Scenario 'X' not supported.
Instructions
Progress:
- [ ] Step 1: Check prerequisites (bash scripts/check_env.sh)
- [ ] Step 2: Generate the skeleton (scaffold), or copy the closest existing scenario
- [ ] Step 3: Fill in _initialize_actors, _create_behavior, _create_test_criteria
- [ ] Step 4: Validate offline (validate) — imports, class/type match, tree shape
- [ ] Step 5: Run it (run-scenario), iterate with DEBUG=1
Step 2: Scaffold
source scripts/env.sh
# a standalone scenario with a config, in the checkout
python3 scripts/scaffold_scenario.py --name MyCutIn --town Town04 \
--template follow_leading_vehicle
# somewhere else, to keep the checkout clean (use --additionalScenario to run it)
python3 scripts/scaffold_scenario.py --name MyCutIn --town Town04 --out ~/my_scenarios
python3 scripts/scaffold_scenario.py --list-templates
The scaffold writes both files with the four methods stubbed, the imports that
actually exist in this branch, and a CollisionTest criterion so the run reports
something. Then edit.
Step 3: The four methods
class MyCutIn(BasicScenario):
def __init__(self, world, ego_vehicles, config, randomize=False,
debug_mode=False, criteria_enable=True, timeout=60):
self.timeout = timeout
self._map = CarlaDataProvider.get_map()
self._reference_waypoint = self._map.get_waypoint(config.trigger_points[0].location)
# scenario parameters come from the XML, via config.other_parameters
self._distance = 50
if "distance" in config.other_parameters:
self._distance = float(config.other_parameters["distance"]["value"])
super().__init__("MyCutIn", ego_vehicles, config, world, debug_mode, criteria_enable=criteria_enable)
def _initialize_actors(self, config):
"""Spawn everything the scenario needs. Use CarlaDataProvider, never world.spawn_actor."""
wp = self._reference_waypoint.next(self._distance)[0]
actor = CarlaDataProvider.request_new_actor("vehicle.tesla.model3", wp.transform)
self.other_actors.append(actor)
def _create_behavior(self):
"""Return the py_trees tree. Composites: Sequence, Parallel; leaves: atomics."""
root = py_trees.composites.Sequence("MyCutIn")
root.add_child(InTriggerDistanceToVehicle(self.other_actors[0], self.ego_vehicles[0], 30))
root.add_child(LaneChange(self.other_actors[0], speed=10, distance_other_lane=30))
root.add_child(ActorDestroy(self.other_actors[0]))
return root
def _create_test_criteria(self):
"""Return a list of criteria. These decide pass/fail."""
return [CollisionTest(self.ego_vehicles[0])]
Rules that are not obvious and cost the most time:
- Spawn through
CarlaDataProvider.request_new_actor, notworld.spawn_actor. Only the provider registers the actor for velocity/transform caching and for cleanup; direct spawns leak between runs and read asnot foundin atomics. - Append to
self.other_actorsor the actor is never destroyed. _create_behaviormust return a tree that terminates. ASequencewhose last child never succeeds hangs until the timeout — which is what an apparently stuck scenario usually is.config.other_parametersis a dict of{name: {attr: value}}built from the XML child elements, and every value is a string. Cast it.self.timeoutmust be set beforesuper().__init__, because the base class reads it while building the tree.- Criteria are attached in parallel with the behaviour and run to the end. An
optional=Truecriterion reports but does not fail the scena
자주 묻는 질문
새 시나리오를 확인하려면 시뮬레이터가 필요한가요?
아니요. 첫 번째 검사는 시뮬레이터 없이 실행되므로, 파일과 이름 오류를 일찍 찾을 수 있습니다.
이름이 정확히 일치해야 하는 이유는 무엇인가요?
테스트 러너는 설정 파일의 이름으로 시나리오를 찾으므로, 오타가 있으면 ‘지원되지 않음’ 오류가 발생합니다.
시나리오를 경로 전체에 추가할 수 있나요?
네. 추가 시나리오 옵션을 사용해 경로에 넣을 수 있습니다.
상세 정보
작성자의 원본 설명
Writes a new ScenarioRunner scenario — a Python class deriving from BasicScenario with its behaviour tree assembled from srunner atomic behaviours and criteria, plus the XML config that gives it a town, ego spawn and parameters — and registers it so `--scenario MyScenario_1` works. Also covers adding a scenario to a route via --additionalScenario. Generates a working skeleton and validates it without a simulator. Use when the user asks to "create/write a new scenario", "add a custom scenario", "make my own traffic situation", or wants to extend the scenario library.
repo: carla-simulator/carla
인기도
- GitHub 스타
- 15k
- 순위
- #11109
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
create-leaderboard-route
15k카메라 화면에서 웨이포인트와 시나리오 트리거를 배치하고, 확인하고, 순서를 정해 CARLA 리더보드 경로 파일을 만들도록 에이전트를 돕습니다.
package-leaderboard-agent
15k주행 에이전트를 CARLA Leaderboard 제출용 Docker 이미지로 패키징하고, 폴더 구조를 확인하며 이미지가 에이전트를 로드하는지 테스트하도록 돕습니다.
read-leaderboard-results
15kCARLA Leaderboard 결과 파일을 읽고 경로별 점수와 위반 사항을 설명하며, 다른 규칙 버전에서 실행을 다시 채점하도록 에이전트를 돕습니다.
run-leaderboard-evaluation
15k주행 에이전트로 경로 세트에 대한 CARLA Leaderboard 평가를 실행하도록 돕습니다. 먼저 설정을 확인하고, 재개할 수 있는 체크포인트를 저장합니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.