Skip to main content
Writing Gazebo world files and 3D model descriptions by hand is tedious and error-prone. Large language models (LLMs) can generate valid SDF XML from plain English descriptions, dramatically accelerating the world-building process. This page covers the techniques, prompt patterns, and tools for LLM-assisted Gazebo asset authoring. This page builds on Gazebo worlds and the SDF/Xacro format, which covers world-file anatomy, the SDF and Xacro schema, the model.config and model.sdf structure, and the AWS RoboMaker Small House world that the examples below extend. Read that page first if you are new to SDF authoring.

Why use LLMs for simulation authoring?

A typical Gazebo model requires coordinating several files: model.config, model.sdf, mesh references, material scripts, and placement poses in the world file. Writing this by hand demands:
  • Knowledge of SDF schema and element nesting rules
  • Correct inertia tensor values for realistic physics
  • Consistent URI conventions (model://name/meshes/...)
  • Collision mesh simplification decisions
LLMs encode knowledge of the SDF schema from training data and can produce syntactically valid XML for common object types in seconds. The human role shifts from author to reviewer and corrector.

Literature review

Several research threads are directly relevant to NLP-to-simulation authoring:

Procedural and generative world creation

Early work on procedural content generation (PCG) for simulation used template engines and grammar-based methods. LLMs represent a qualitative shift: they can interpret underspecified natural language and infer reasonable defaults. WorldGen / SceneX-type approaches, papers such as SceneX (CVPR 2024) and Holodeck (CVPR 2024) demonstrate end-to-end pipelines that convert a text description of a room (“a modern living room with a grey sofa facing a TV”) into a 3D scene with placed furniture. These systems query LLMs to select object categories and spatial relationships, then look up 3D assets from a database (Objaverse, ShapeNet) and assign poses. The core LLM task is structured output generation, producing a JSON or XML scene graph from free text. Code-as-interface, ProgPrompt (ICLR 2023) and Code as Policies (ICRA 2023) show that LLMs are effective at generating robot task programs when given a library of available primitives. The same principle applies to SDF authoring: if the LLM is told what XML elements are available and what each does, it generates structurally correct documents. The SDF schema serves as the “primitive library.” Language-to-simulation bridges, ChatSim (CVPR 2024) specifically targets autonomous driving simulation, converting natural language commands into scene edits in a CARLA/nuScenes-style environment. The authors use a multi-agent LLM pipeline where one agent interprets the command, another places objects, and a third checks physical plausibility.

Prompt engineering for structured output

Getting an LLM to produce valid XML consistently requires careful prompt design:
  1. Schema injection, include the relevant portion of the SDF specification in the system prompt. Modern long-context models (Claude, GPT-4o) can hold the full SDF 1.6 schema and still produce coherent output.
  2. Few-shot examples, provide one or two complete model.sdf examples before the request. LLMs are highly sensitive to format exemplars.
  3. Validation feedback loop, pipe the generated XML through gz sdf --check and feed errors back as user messages for iterative correction.
  4. Decomposition, generate the collision mesh description and visual mesh description separately, then combine. Monolithic generation of complex models degrades quality.

Mesh generation

SDF model files reference .DAE (COLLADA) or .OBJ meshes for geometry. LLMs generate the description of the model, but mesh files must come from one of:
  • 3D asset libraries, Google Poly, Sketchfab, AWS RoboMaker models
  • Procedural geometry, for simple shapes (boxes, cylinders, L-shaped objects), SDF primitive geometry suffices and requires no mesh file
  • Text-to-3D models, Shap-E (OpenAI, 2023) and One-2-3-45 generate meshes from text or images; quality is improving rapidly but remains lower than hand-authored assets for precise collision models
For classroom exercises, SDF primitive geometry (boxes, cylinders, spheres) is the recommended starting point. It requires no mesh files and the LLM can generate the complete SDF without any external assets.

Prompt patterns

Pattern 1: Generate a model from a description

Use this pattern to create a new model.sdf for a simple object using primitive geometry. System prompt:
User prompt:
Example LLM output:

Pattern 2: Place models in a world file

Use this pattern to generate the <model> placement blocks for a room layout. User prompt:
Example LLM output:

Pattern 3: Iterative correction with validation feedback

After generating SDF, validate it with the Gazebo command-line tool and feed errors back to the LLM:
If validation fails, append the error to the conversation:
The LLM will correct the specific element while preserving the rest of the file. This loop typically converges in 1–3 iterations for straightforward models.

Worked example: generating a new appliance model

The AWS Small House world includes air conditioners (AirconditionerA_01) but no ceiling fan. Here is how to generate one using the LLM workflow.

Step 1: Describe the object

Step 2: Generate

Send the prompt to your preferred LLM (Claude, GPT-4o). The response will be a complete model.sdf using <cylinder> and <box> primitives.

Step 3: Create model directory

Create model.config:
Save the generated SDF as model.sdf in the same directory.

Step 4: Validate

Fix any errors by feeding them back to the LLM.

Step 5: Place in the world

Add a placement block to house_world.sdf.xacro:

Step 6: Launch and inspect

Open Gazebo and verify the fan appears at the correct location. If the position is wrong, adjust the <pose> values and restart.

Common failure modes and fixes


Integration with the TurtleBot demo

Adding new models to the house world affects robot navigation in two ways: 1. Obstacle map, If a model has a <collision> element, Nav2 will detect it as an obstacle via the LiDAR scan. Static furniture that the robot should navigate around must have collision geometry. 2. Camera perception, New objects may be detected by the YOLOv8 or HSV vision pipeline. If you add a bright red object to the scene, the HSV detector (targeting TARGET_COLOR=red) will report a detection when the robot looks at it. After modifying the world, re-run SLAM to generate an updated map:

Further reading