Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:ARISE Initiative Robosuite USDShapes

From Leeroopedia
Knowledge Sources
Domains Robotics, 3D Rendering, Computational Geometry
Last Updated 2026-02-15 07:00 GMT

Overview

The USDShapes module provides built-in geometric shape primitives and mesh generation utilities for the USD exporter, including boxes, spheres, hemispheres, and cylinders with UV texture mapping.

Description

This module contains the TriangleMesh class and a set of helper functions for generating and configuring 3D mesh primitives used in USD scene construction. The TriangleMesh class stores vertex positions, triangle indices, and UV coordinates, and provides class methods for creating standard geometric shapes: create_box, create_sphere, create_hemisphere, and create_cylinder. Each creation method computes appropriate UV coordinates based on the MuJoCo texture type (2D, cube, or skybox).

The module also provides two key factory functions. mesh_config_generator creates configuration dictionaries for each MuJoCo geometry type (plane, sphere, capsule, ellipsoid, cylinder, box), translating MuJoCo size parameters into mesh dimensions. For compound shapes like capsules, it generates multi-part configurations (cylinder body plus hemisphere end caps). mesh_factory takes these configurations and produces actual TriangleMesh instances, applying optional transformations (rotation, scaling, translation) and compositing multiple sub-meshes into a single object via the __add__ operator.

The decouple_config function breaks compound shape configurations into independent sub-component shapes, which is used for tendon rendering where each part needs independent transform control.

Usage

Use this module when you need to generate triangle mesh representations of MuJoCo primitive geometry types for USD export. The functions are called internally by USDPrimitiveMesh and USDTendon objects in the USD object module.

Code Reference

Source Location

Signature

class TriangleMesh:
    def __init__(self, vertices: np.ndarray, triangles: np.ndarray, triangle_uvs: np.ndarray)

    @classmethod
    def create_box(cls, width: float, height: float, depth: float,
                   texture_type: Optional[mujoco.mjtTexture]) -> "TriangleMesh"

    @classmethod
    def create_sphere(cls, radius: float, texture_type: Optional[mujoco.mjtTexture],
                      resolution: int) -> "TriangleMesh"

    @classmethod
    def create_hemisphere(cls, radius: float, texture_type: Optional[mujoco.mjtTexture],
                          resolution: int) -> "TriangleMesh"

    @classmethod
    def create_cylinder(cls, radius: float, height: float,
                        texture_type: Optional[mujoco.mjtTexture],
                        resolution: int) -> "TriangleMesh"

def mesh_config_generator(name: str, geom_type: Union[int, mujoco.mjtGeom],
                          size: np.ndarray, decouple: bool = False)

def mesh_factory(mesh_config: Dict[str, Any], texture_type: Optional[mujoco.mjtTexture],
                 resolution: int = 100)

def get_triangle_uvs(vertices: np.ndarray, triangles: np.ndarray,
                     texture_type: Optional[mujoco.mjtTexture])

def decouple_config(config: Dict[str, Any])

Import

import robosuite.utils.usd.shapes as shapes_module
# or
from robosuite.utils.usd.shapes import TriangleMesh, mesh_config_generator, mesh_factory

I/O Contract

Inputs

Name Type Required Description
vertices np.ndarray Yes (TriangleMesh) Array of 3D vertex positions
triangles np.ndarray Yes (TriangleMesh) Array of triangle face indices
triangle_uvs np.ndarray Yes (TriangleMesh) Array of UV texture coordinates
name str Yes (mesh_config_generator) Name for the mesh configuration
geom_type mujoco.mjtGeom Yes (mesh_config_generator) MuJoCo geometry type constant
size np.ndarray Yes (mesh_config_generator) Size parameters for the geometry
decouple bool No Whether to break config into independent sub-components (default: False)
mesh_config Dict[str, Any] Yes (mesh_factory) Configuration dictionary for mesh generation
texture_type Optional[mujoco.mjtTexture] Yes (mesh_factory) MuJoCo texture type for UV mapping
resolution int No Resolution for sphere/hemisphere/cylinder tessellation (default: 100)

Outputs

Name Type Description
TriangleMesh TriangleMesh A mesh object containing vertices, triangles, and UV coordinates
mesh_config dict Configuration dictionary from mesh_config_generator
(name, mesh) tuple Tuple of (mesh_name, TriangleMesh) from mesh_factory

Usage Examples

import numpy as np
import mujoco
from robosuite.utils.usd.shapes import TriangleMesh, mesh_config_generator, mesh_factory

# Create a box mesh directly
box = TriangleMesh.create_box(
    width=1.0, height=1.0, depth=1.0,
    texture_type=mujoco.mjtTexture.mjTEXTURE_2D
)

# Generate a mesh config from MuJoCo geom parameters
config = mesh_config_generator(
    name="my_sphere",
    geom_type=mujoco.mjtGeom.mjGEOM_SPHERE,
    size=np.array([0.5]),
)

# Create the actual mesh from the config
name, mesh = mesh_factory(config, texture_type=None, resolution=50)

# Combine meshes using the + operator
combined = box + mesh

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment