create-scenario
यह क्या करती है
यह स्किल CARLA सिमुलेटर के लिए नया ड्राइविंग टेस्ट परिदृश्य लिखती है, जिसमें उसके एक्टर, व्यवहार और पास होने की शर्तें शामिल हैं। यह उन डेवलपर्स के लिए है जो सेल्फ़-ड्राइविंग सॉफ़्टवेयर के लिए कस्टम टेस्ट बना रहे हैं।
कब इस्तेमाल करें
- ✓जब आप ऐसा नया टेस्ट चाहते हैं जिसमें कार को किसी खास सड़क स्थिति से निपटना हो।
- ✓जब आपको परिदृश्य फ़ाइल चाहिए जिसे टेस्ट रनर नाम से ढूँढकर चला सके।
- ✓जब सिमुलेटर पर चलाने से पहले नए परिदृश्य में गड़बड़ियों की जाँच करवानी हो।
Skill का लिंक
https://github.com/carla-simulator/carla/blob/ue58-dev/Skills/scenario-runner/create-scenario/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप CARLA का एक नया टेस्ट लिख सकते हैं जिसमें दूसरी कार अचानक मेरी कार के सामने आ जाए, और जाँच सकते हैं कि वह सही लोड होता है?”
हर हफ़्ते 5 नई skills, 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
अक्सर पूछे जाने वाले सवाल
क्या नए परिदृश्य की जाँच के लिए सिमुलेटर चाहिए?
नहीं। पहली जाँच इसके बिना चलती है, ताकि फ़ाइल और नाम की गड़बड़ियाँ जल्दी पकड़ी जा सकें।
नाम बिल्कुल मेल क्यों खाना चाहिए?
टेस्ट रनर कॉन्फ़िग फ़ाइल में दिए नाम से परिदृश्य ढूँढता है, इसलिए गलत वर्तनी 'not supported' एरर देती है।
क्या मैं परिदृश्य को पूरे रूट में जोड़ सकता हूँ?
हाँ। इसे एक अतिरिक्त परिदृश्य विकल्प से रूट में जोड़ा जा सकता है।
जानकारी
लेखक का मूल विवरण
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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
create-leaderboard-route
15kयह आपके एजेंट को CARLA Leaderboard की रूट फ़ाइल बनाने में मदद करती है, जिसमें वेपॉइंट और सीन ट्रिगर कैमरे से लगाए जाते हैं।
package-leaderboard-agent
15kयह आपके एजेंट को CARLA Leaderboard के लिए Docker इमेज बनाने में मदद करती है, और जाँचती है कि इमेज में एजेंट सही लोड होता है।
read-leaderboard-results
15kयह आपके एजेंट को CARLA Leaderboard की नतीजा फ़ाइल पढ़कर हर रूट का स्कोर समझाने और दूसरे नियम संस्करण में फिर से स्कोर करने में मदद करती है।
run-leaderboard-evaluation
15kयह आपके एजेंट को रूट के सेट पर CARLA Leaderboard मूल्यांकन चलाने में मदद करती है, शुरू करने से पहले सेटअप जाँचकर और चेकपॉइंट सेव करके।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।