File size: 12,893 Bytes
eb14f7a 86b57ca eb14f7a 86b57ca eb14f7a d98c9f8 86b57ca 392d0de ac18756 59bc8b3 eb14f7a 86b57ca eb14f7a 86b57ca eb14f7a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | # Convex Decomposition Storage Specification
Convex decomposition outputs are derived assets. They must not overwrite raw meshes or upstream XML files.
## Path layout
Store convex decomposition results under:
```text
assets/<source>/derived/convex_decompositions/<category>/<asset_id>/
```
Example for a RoboCasa dishwasher:
```text
assets/robocasa/derived/convex_decompositions/dishwashers/Dishwasher031_vhacd_v1/
├── metadata.yaml
├── source_refs.yaml
├── meshes/
│ ├── door/
│ │ ├── part_000.obj
│ │ ├── part_001.obj
│ │ └── ...
│ ├── rack0/
│ └── rack1/
├── mjcf/
│ ├── convex_assets_include.xml
│ ├── convex_geoms_include.xml
│ └── convex_collision_include.xml
└── logs/
└── decomposition.json
```
Example for a DISCOVERSE object:
```text
assets/discoverse/derived/convex_decompositions/objects/cup_vhacd_v1/
├── metadata.yaml
├── source_refs.yaml
├── meshes/
│ └── cup/
│ ├── part_000.obj
│ └── part_001.obj
├── mjcf/
│ ├── convex_assets_include.xml
│ ├── convex_geoms_include.xml
│ └── convex_collision_include.xml
└── logs/
└── decomposition.json
```
## Required files
### Scaffold command
Use the helper script to create the derived asset skeleton:
```bash
python scripts/scaffold_convex_decomposition.py assets/robocasa/raw/fixtures/dishwashers/Dishwasher031
```
This creates a new directory under `assets/robocasa/derived/convex_decompositions/...` with placeholder metadata, source references, logs, and MJCF include files. Fill in the generated meshes and replace placeholders before adding the asset to `manifest/assets.jsonl`.
### Run CoACD decomposition
Use `scripts/run_convex_decomposition.py` when you want to actually generate convex parts and MuJoCo include files:
```bash
pip install trimesh coacd
python scripts/run_convex_decomposition.py \
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
--mesh visuals/door.obj \
--mesh visuals/rack0.obj \
--variant coacd_v1 \
--register-manifest
```
If `--mesh` is omitted, the script searches common mesh locations under the raw asset directory:
```text
visuals/*.obj
visuals/*.stl
meshes/*.obj
meshes/*.stl
```
The script writes generated pieces to `meshes/<mesh_name>/part_000.obj`, records hashes and parameters in `logs/decomposition.json`, and creates MJCF include files under `mjcf/`.
For each generated convex part, the script also records size and complexity statistics in both `logs/decomposition.json` and `logs/parts_summary.csv`:
```text
bbox_extents # x/y/z axis-aligned bounding-box dimensions
bbox_center # axis-aligned bounding-box center
bbox_volume
mesh_volume
surface_area
num_vertices
num_faces
```
Use `logs/parts_summary.csv` to find parts that are too small, too large, or unexpectedly complex before using them as collision geometry.
### Decomposition granularity controls
CoACD does not directly support a target physical bbox size such as "each part should be about 5 cm". Part size is controlled indirectly through decomposition granularity parameters:
```text
--threshold Lower value -> stricter convex approximation -> usually more/smaller parts.
--max-convex-hull Caps the number of convex hulls. Lower cap -> fewer/larger parts.
--no-merge Disables hull merge. Usually keeps more/smaller parts.
--mcts-max-depth Higher value allows deeper recursive splitting.
--mcts-nodes
--mcts-iterations More search can find finer/better splits, with higher runtime.
--preprocess-resolution
--resolution Higher values preserve more geometric detail before decomposition.
--max-ch-vertex Controls complexity of each convex hull, not physical size directly.
```
Practical presets:
```bash
# Coarser collision: fewer/larger parts, faster simulation
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh <mesh.obj> \
--threshold 0.08 \
--max-convex-hull 8
# Finer collision: more/smaller parts, more accurate but heavier
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh <mesh.obj> \
--threshold 0.02 \
--max-convex-hull 32 \
--no-merge \
--mcts-max-depth 4
```
After generation, inspect `logs/parts_summary.csv` to decide whether the resulting part sizes are acceptable for the target task.
## Full script usage
Print the current CLI help:
```bash
python scripts/run_convex_decomposition.py --help
```
General form:
```bash
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh <mesh_path_relative_to_raw_asset_dir> \
--variant <variant_name> \
[CoACD options] \
[MJCF options] \
[repository options]
```
### Required argument
| Argument | Meaning |
| --- | --- |
| `raw_asset_dir` | Raw asset directory under `assets/<source>/raw/<asset_type>/<category>/<asset_id>/`. |
### Input selection
| Option | Default | Meaning |
| --- | --- | --- |
| `--mesh <path>` | none | Mesh to decompose. Path can be relative to `raw_asset_dir` or absolute. Repeat this option for multiple meshes. |
| `--mesh-glob <glob>` | `visuals/*.obj`, `visuals/*.stl`, `meshes/*.obj`, `meshes/*.stl` | Glob used when `--mesh` is omitted. Repeatable. |
Example:
```bash
python scripts/run_convex_decomposition.py \
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
--mesh visuals/door.obj \
--mesh visuals/rack0.obj \
--mesh visuals/rack1.obj
```
### Repository/output options
| Option | Default | Meaning |
| --- | --- | --- |
| `--variant <name>` | `coacd_v1` | Output suffix. The derived asset directory becomes `<source_asset_id>_<variant>`. |
| `--overwrite` | false | Allow writing into an existing derived output directory. Use cautiously. |
| `--register-manifest` | false | Append the generated derived asset to `manifest/assets.jsonl`. Use only for outputs you intend to keep. |
Output path:
```text
assets/<source>/derived/convex_decompositions/<category>/<source_asset_id>_<variant>/
```
### MJCF options
| Option | Default | Meaning |
| --- | --- | --- |
| `--class-name <name>` | `convex_collision` | `class` attribute for generated `<geom>` entries. Empty string disables it. |
| `--rgba "r g b a"` | `0.8 0.2 0.2 0.35` | RGBA for generated collision geoms. |
| `--group <int>` | `0` | MuJoCo geom group. Empty string disables it. |
| `--contype <int>` | empty | MuJoCo contact type. Empty means use MuJoCo default. |
| `--conaffinity <int>` | empty | MuJoCo contact affinity. Empty means use MuJoCo default. |
Generated MJCF files:
```text
mjcf/convex_assets_include.xml # include at MJCF root/top level
mjcf/convex_geoms_include.xml # include inside the target body
mjcf/convex_collision_include.xml # standalone wrapper for preview/convenience
```
### CoACD granularity and quality options
| Option | Default | Effect |
| --- | --- | --- |
| `--threshold <float>` | `0.05` | Main concavity threshold. Lower values usually create more/smaller and more accurate parts. Higher values create fewer/coarser parts. |
| `--max-convex-hull <int>` | `-1` | Maximum hull count. `-1` means CoACD default/unlimited. Lower cap forces fewer/larger parts. |
| `--no-merge` | false | Disable CoACD hull merge. Usually preserves more/smaller parts. Useful for wire/rack-like geometry, but may create many parts. |
| `--mcts-max-depth <int>` | `3` | Maximum recursive split depth. Higher values can produce finer decomposition and longer runtime. |
| `--mcts-nodes <int>` | `20` | Search nodes per MCTS step. Higher values can improve split search and increase runtime. |
| `--mcts-iterations <int>` | `150` | MCTS iterations. Higher values can improve split quality and increase runtime. |
| `--resolution <int>` | `2000` | CoACD sampling/resolution parameter. Higher values preserve more detail and cost more time. |
| `--preprocess-mode {auto,on,off}` | `auto` | Whether CoACD preprocesses the input mesh. |
| `--preprocess-resolution <int>` | `50` | Resolution for preprocessing. Higher values may preserve more detail and cost more time. |
| `--max-ch-vertex <int>` | `256` | Maximum vertices per convex hull. Controls hull complexity, not physical part size directly. |
| `--pca` | false | Enable CoACD PCA mode. Can affect orientation/splitting behavior. |
| `--decimate` | false | Enable CoACD decimation. May simplify output. |
| `--extrude` | false | Enable CoACD extrusion. |
| `--extrude-margin <float>` | `0.01` | Margin used when extrusion is enabled. |
| `--apx-mode {ch,box}` | `ch` | Approximation mode: convex hull or box approximation. |
| `--real-metric` | false | Enable CoACD `real_metric` option if supported. |
| `--seed <int>` | `0` | Random seed for reproducible runs where CoACD supports it. |
### Practical parameter presets
Block-like assets such as doors, panels, and shells:
```bash
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh visuals/door.obj \
--variant coacd_v1 \
--threshold 0.05 \
--max-convex-hull 16
```
Coarser and faster collision:
```bash
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh <mesh.obj> \
--variant coacd_coarse_v1 \
--threshold 0.08 \
--max-convex-hull 8
```
Finer collision:
```bash
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh <mesh.obj> \
--variant coacd_fine_v1 \
--threshold 0.02 \
--max-convex-hull 32 \
--no-merge \
--mcts-max-depth 4
```
Rack/wire-like assets such as dishwasher racks:
```bash
python scripts/run_convex_decomposition.py <raw_asset_dir> \
--mesh visuals/rack1.obj \
--variant rack1_coacd_trial \
--threshold 0.02 \
--max-convex-hull 128 \
--no-merge \
--resolution 2000 \
--mcts-max-depth 4
```
For rack/wire-like assets, inspect `logs/parts_summary.csv` and visualize the result before registering it. A valid result should not have convex hulls that bridge functional slots or gaps. If the decomposition needs hundreds of parts, primitive collision using capsules/boxes is usually a better engineering choice.
### `metadata.yaml`
Minimum fields:
```yaml
asset_id: robocasa.convex_decompositions.dishwashers.Dishwasher031_vhacd_v1
source: robocasa
asset_type: convex_decompositions
category: dishwashers
source_asset_id: Dishwasher031
format: obj_mjcf_include
entry_file: mjcf/convex_collision_include.xml
license: CC-BY-4.0
origin_url: https://robocasa.ai
path: assets/robocasa/derived/convex_decompositions/dishwashers/Dishwasher031_vhacd_v1
storage_mode: derived
derived_from:
- assets/robocasa/raw/fixtures/dishwashers/Dishwasher031
derivation_method: convex_decomposition
decomposition_tool: vhacd
decomposition_version: TBD
decomposition_params_file: logs/decomposition.json
validation_status: pending
tags:
- robocasa
- convex_decomposition
- collision
- mujoco
```
### `source_refs.yaml`
Record exact source files:
```yaml
raw_asset: assets/robocasa/raw/fixtures/dishwashers/Dishwasher031
raw_entry_file: assets/robocasa/raw/fixtures/dishwashers/Dishwasher031/model.xml
raw_meshes:
- assets/robocasa/raw/fixtures/dishwashers/Dishwasher031/visuals/door.obj
- assets/robocasa/raw/fixtures/dishwashers/Dishwasher031/visuals/rack0.obj
```
### `logs/decomposition.json`
Record tool parameters and hashes:
```json
{
"tool": "vhacd",
"tool_version": "TBD",
"created_at": "YYYY-MM-DD",
"params": {},
"inputs": [
{
"path": "assets/robocasa/raw/fixtures/dishwashers/Dishwasher031/visuals/door.obj",
"sha256": "TBD"
}
],
"outputs": [
{
"path": "meshes/door/part_000.obj",
"sha256": "TBD"
}
]
}
```
## MJCF integration rule
Do not edit raw `model.xml` in place. If MuJoCo collision integration is needed, write a generated include file under:
```text
mjcf/
```
Generated MJCF should be split by include context:
```text
mjcf/convex_assets_include.xml # include at MJCF root/top level
mjcf/convex_geoms_include.xml # include inside the target body
mjcf/convex_collision_include.xml # standalone wrapper for preview/convenience
```
Recommended integration pattern:
```xml
<!-- top level -->
<include file="path/to/mjcf/convex_assets_include.xml"/>
<!-- inside the object body that should receive collision geoms -->
<include file="path/to/mjcf/convex_geoms_include.xml"/>
```
This split avoids mixing root-level `<asset>` declarations with body-level `<geom>` declarations. `convex_collision_include.xml` is provided as a convenience wrapper body and should not be used when replacing collision geometry inside an existing body hierarchy.
## Manifest rule
Convex decomposition results are real derived assets and must be indexed in:
```text
manifest/assets.jsonl
```
Link-only plans or empty placeholders should not be listed in the manifest.
|