File size: 9,452 Bytes
54277cb 04d033d 54277cb 04d033d 54277cb 504e487 54277cb 504e487 54277cb | 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 | # Primitive Collision Proxy Storage Specification
Primitive collision proxies are derived assets. They are intended for thin rods, racks, grids, shelves, and slot-like structures where coarse convex decomposition can close functional gaps and very fine convex decomposition can create too many mesh collisions.
Do not overwrite raw meshes or upstream XML files.
## Path layout
Store primitive proxy results under:
```text
assets/<source>/derived/primitive_collision_proxies/<category>/<asset_id>/
```
Example for a RoboCasa dishwasher rack:
```text
assets/robocasa/derived/primitive_collision_proxies/dishwashers/Dishwasher031_rack1_primitive_boxes_v1/
├── metadata.yaml
├── source_refs.yaml
├── README.md
├── REPORT.md
├── proxy/
│ └── primitive_collision_proxy.json
├── mjcf/
│ ├── primitive_geoms_include.xml
│ └── primitive_collision_include.xml
├── curobo/
│ └── primitive_world.yml
└── logs/
├── cuboids_summary.csv
└── proxy_generation.json
```
## When to use this instead of convex decomposition
Use primitive proxies when the collision model must preserve gaps or slots:
- dishwasher racks
- wire baskets
- grilles
- thin support rods
- slot separators
For block-like meshes such as doors, panels, shells, and drawer fronts, prefer CoACD convex decomposition:
```text
docs/convex_decomposition_spec.md
```
## Source of truth
The canonical generated representation is:
```text
proxy/primitive_collision_proxy.json
```
MuJoCo and cuRobo exports are generated from the same proxy JSON:
```text
mjcf/primitive_geoms_include.xml
curobo/primitive_world.yml
```
This is important because simulation and planning should use the same collision approximation whenever possible.
## Run primitive proxy generation
Basic command:
```bash
python scripts/run_primitive_collision_proxy.py \
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
--mesh visuals/rack1.obj \
--variant rack1_primitive_boxes_v1
```
Register a production-ready derived output in the manifest:
```bash
python scripts/run_primitive_collision_proxy.py \
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
--mesh visuals/rack1.obj \
--variant rack1_primitive_boxes_v1 \
--register-manifest
```
Do not use `--register-manifest` for temporary inspection runs.
## Full script usage
Print current CLI help:
```bash
python scripts/run_primitive_collision_proxy.py --help
```
General form:
```bash
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
--mesh <mesh_path_relative_to_raw_asset_dir> \
--variant <variant_name> \
[proxy 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 | OBJ mesh to convert to primitive boxes. Path can be relative to `raw_asset_dir` or absolute. Repeat this option for multiple meshes. |
| `--mesh-glob <glob>` | `visuals/rack1.obj` | Glob used when `--mesh` is omitted. Repeatable. |
The script currently parses OBJ geometry directly. Use OBJ input for this tool.
### Repository/output options
| Option | Default | Meaning |
| --- | --- | --- |
| `--variant <name>` | `primitive_boxes_v1` | Output suffix. The derived asset directory becomes `<source_asset_id>_<variant>`. |
| `--output-dir <path>` | canonical derived path | Optional explicit output directory for inspection. Do not use with `--register-manifest`. |
| `--overwrite` | false | Allow writing into an existing output directory. Use cautiously. |
| `--register-manifest` | false | Append the generated derived asset to `manifest/assets.jsonl`. Use only for outputs intended to be kept. |
Compatibility rule:
- Registered assets must use the canonical path under `assets/<source>/derived/primitive_collision_proxies/<category>/<asset_id>/`.
- `--output-dir` is for temporary inspection only and is rejected when combined with `--register-manifest`.
### Proxy generation options
| Option | Default | Meaning |
| --- | --- | --- |
| `--name-prefix <prefix>` | `proxy` | Prefix for generated cuboid and MuJoCo geom names. |
| `--segment-length <float>` | `0.03` | Maximum segment length before splitting a connected component along its longest axis. Smaller values produce more/shorter boxes. |
| `--padding <float>` | `0.001` | Extra half-extent added to each generated cuboid. Larger values make collision more conservative. |
| `--min-half-extent <float>` | `0.0015` | Minimum half-extent per cuboid axis. Prevents zero-thickness boxes. |
| `--min-component-vertices <int>` | `4` | Discard connected components with fewer vertices. |
| `--min-segment-vertices <int>` | `2` | Discard split segments with fewer vertices. |
| `--allowed-contact-target X Y Z` | none | OBJ-local point used to mark nearby cuboids as allowed-contact. |
| `--allowed-contact-radius <float>` | `0.03` | Radius around allowed-contact target. Cuboids whose centers are inside this radius are marked as `allowed_contact`. |
The generated proxy categories are:
```text
forbidden # exported to MuJoCo and cuRobo
allowed_contact # exported to MuJoCo for review, omitted from cuRobo forbidden world
```
Use allowed-contact marking for task-specific regions where contact is expected or permitted. Do not treat it as a full physical validation.
### MJCF options
| Option | Default | Meaning |
| --- | --- | --- |
| `--class-name <name>` | `primitive_collision` | `class` attribute for generated `<geom>` entries. Empty string disables it. |
| `--rgba-forbidden "r g b a"` | `0.8 0.1 0.1 0.45` | RGBA for forbidden cuboids. |
| `--rgba-allowed "r g b a"` | `0.1 0.6 1 0.45` | RGBA for allowed-contact cuboids. |
| `--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/primitive_geoms_include.xml # include inside the target body
mjcf/primitive_collision_include.xml # standalone wrapper for preview/convenience
mjcf/preview_world.xml # MuJoCo preview scene with raw visual mesh + collision boxes
```
Recommended integration:
```xml
<!-- inside the object body that should receive primitive collision geoms -->
<include file="path/to/mjcf/primitive_geoms_include.xml"/>
```
For visual debugging in MuJoCo, open:
```text
mjcf/preview_world.xml
```
This preview keeps the original visual mesh in gray and the primitive boxes in red.
By default, the red collision boxes are hidden. Press `C` in `scripts/open_mujoco_preview.py` to toggle them on and off.
## Output files
### `proxy/primitive_collision_proxy.json`
Contains:
- format marker
- generation params
- source mesh stats
- cuboid list
- each cuboid's name, source mesh, category, position, half-size, full dimensions, component index, and segment index
### `logs/cuboids_summary.csv`
Tabular summary for inspection:
```text
name
source_mesh
category
component
segment
pos_x / pos_y / pos_z
size_x / size_y / size_z # MuJoCo half-size
dim_x / dim_y / dim_z # full dimensions
```
Use this file to identify boxes that are too long, too thick, or unexpectedly spanning a slot.
### `curobo/primitive_world.yml`
cuRobo cuboid fragment generated from `forbidden` cuboids only. `allowed_contact` cuboids are intentionally omitted.
### `REPORT.md`
Human-readable generation report with mesh stats, cuboid counts, largest cuboids, and a review checklist.
## Practical presets
Dishwasher rack first pass:
```bash
python scripts/run_primitive_collision_proxy.py \
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
--mesh visuals/rack1.obj \
--variant rack1_primitive_boxes_v1 \
--segment-length 0.03 \
--padding 0.001 \
--min-half-extent 0.0015
```
Finer boxes:
```bash
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
--mesh visuals/rack1.obj \
--variant rack1_primitive_boxes_fine_v1 \
--segment-length 0.015 \
--padding 0.0005 \
--min-half-extent 0.001
```
Coarser boxes:
```bash
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
--mesh visuals/rack1.obj \
--variant rack1_primitive_boxes_coarse_v1 \
--segment-length 0.06 \
--padding 0.0015 \
--min-half-extent 0.002
```
## Review checklist
Before registering primitive proxies in `manifest/assets.jsonl`:
- Open or render `mjcf/primitive_geoms_include.xml` with the visual mesh.
- Confirm boxes do not bridge functional rack slots.
- Confirm boxes are not much thicker than the intended rod/wire collision margin.
- Confirm the chosen `segment-length` is not creating too many boxes for MuJoCo or cuRobo.
- Confirm allowed-contact cuboids, if used, are task-specific and documented.
- Run:
```bash
python scripts/validate_asset.py assets/<source>/derived/primitive_collision_proxies/<category>/<asset_id>
python scripts/validate_asset.py --all
```
## Manifest rule
Primitive proxy results are real derived assets and must be indexed in:
```text
manifest/assets.jsonl
```
Only register reviewed outputs that should be reused. Temporary trials should not be listed in the manifest.
|