> For the complete documentation index, see [llms.txt](https://docs.hello-robot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hello-robot.com/stretch4_mujoco/stretch4_mujoco/models/stretch_4.md).

# Stretch 4 MJCF and URDF

The MJCF is now dynamically generated on-the-fly from the `stretch4_urdf` package using `urdf2mjcf` and programmatic DOM manipulations.

When the simulator is initialized, `get_robot_xml_path()` dynamically invokes `mjcf_generator.py` to convert the appropriate URDF into an MJCF and applies custom modifications required by Mujoco.

## Programmatic Transformations Applied

The `mjcf_generator.py` applies the following changes to the raw `urdf2mjcf` output:

1. Removes all tags except `asset` and `worldbody`.
2. Removes specific tags from worldbody (e.g., `light`, `camera`, `ground` plane).
3. Replaces the default wheel joints with custom bodies (`link_left_wheel`, `link_right_wheel`, `link_back_wheel`) containing `class="wheel"` and associated wheel rollers to support omnibase motion, and includes `omniwheels.xml`.
4. Encapsulates lidar and camera geoms with dedicated bodies and includes `hemisphere_lidar_cameras_right/left.xml`.
5. Replaces `link_mast` geometry with appropriate `collision` and `visualgeom` classes.
6. Renames the root body to `base_link` and adds an `imu` site.
7. Encapsulates gripper fingers into `link_gripper_slider` (if present, e.g. for sg4 tool).
8. Adjusts `class="visualgeom"` and adds `class="rubber"` to gripper fingers.
9. Modifies wrist roll to include `gripper_cameras.xml`.
10. Adds `gravcomp="1"` to lift, arm, and wrist components.
11. Maps joints to appropriate classes defined in `defaults.xml` (`lift_stretch4`, `telescope`, `wrist_yaw_stretch4`, etc.).

These steps have been fully automated and replace the previously documented manual processes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hello-robot.com/stretch4_mujoco/stretch4_mujoco/models/stretch_4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
