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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Primitive Collision Proxy Storage Specification
|
| 2 |
+
|
| 3 |
+
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.
|
| 4 |
+
|
| 5 |
+
Do not overwrite raw meshes or upstream XML files.
|
| 6 |
+
|
| 7 |
+
## Path layout
|
| 8 |
+
|
| 9 |
+
Store primitive proxy results under:
|
| 10 |
+
|
| 11 |
+
```text
|
| 12 |
+
assets/<source>/derived/primitive_collision_proxies/<category>/<asset_id>/
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
Example for a RoboCasa dishwasher rack:
|
| 16 |
+
|
| 17 |
+
```text
|
| 18 |
+
assets/robocasa/derived/primitive_collision_proxies/dishwashers/Dishwasher031_rack1_primitive_boxes_v1/
|
| 19 |
+
├── metadata.yaml
|
| 20 |
+
├── source_refs.yaml
|
| 21 |
+
├── README.md
|
| 22 |
+
├── REPORT.md
|
| 23 |
+
├── proxy/
|
| 24 |
+
│ └── primitive_collision_proxy.json
|
| 25 |
+
├── mjcf/
|
| 26 |
+
│ ├── primitive_geoms_include.xml
|
| 27 |
+
│ └── primitive_collision_include.xml
|
| 28 |
+
├── curobo/
|
| 29 |
+
│ └── primitive_world.yml
|
| 30 |
+
└── logs/
|
| 31 |
+
├── cuboids_summary.csv
|
| 32 |
+
└── proxy_generation.json
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## When to use this instead of convex decomposition
|
| 36 |
+
|
| 37 |
+
Use primitive proxies when the collision model must preserve gaps or slots:
|
| 38 |
+
|
| 39 |
+
- dishwasher racks
|
| 40 |
+
- wire baskets
|
| 41 |
+
- grilles
|
| 42 |
+
- thin support rods
|
| 43 |
+
- slot separators
|
| 44 |
+
|
| 45 |
+
For block-like meshes such as doors, panels, shells, and drawer fronts, prefer CoACD convex decomposition:
|
| 46 |
+
|
| 47 |
+
```text
|
| 48 |
+
docs/convex_decomposition_spec.md
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Source of truth
|
| 52 |
+
|
| 53 |
+
The canonical generated representation is:
|
| 54 |
+
|
| 55 |
+
```text
|
| 56 |
+
proxy/primitive_collision_proxy.json
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
MuJoCo and cuRobo exports are generated from the same proxy JSON:
|
| 60 |
+
|
| 61 |
+
```text
|
| 62 |
+
mjcf/primitive_geoms_include.xml
|
| 63 |
+
curobo/primitive_world.yml
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
This is important because simulation and planning should use the same collision approximation whenever possible.
|
| 67 |
+
|
| 68 |
+
## Run primitive proxy generation
|
| 69 |
+
|
| 70 |
+
Basic command:
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
python scripts/run_primitive_collision_proxy.py \
|
| 74 |
+
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
|
| 75 |
+
--mesh visuals/rack1.obj \
|
| 76 |
+
--variant rack1_primitive_boxes_v1
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Register a production-ready derived output in the manifest:
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
python scripts/run_primitive_collision_proxy.py \
|
| 83 |
+
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
|
| 84 |
+
--mesh visuals/rack1.obj \
|
| 85 |
+
--variant rack1_primitive_boxes_v1 \
|
| 86 |
+
--register-manifest
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Do not use `--register-manifest` for temporary inspection runs.
|
| 90 |
+
|
| 91 |
+
## Full script usage
|
| 92 |
+
|
| 93 |
+
Print current CLI help:
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
python scripts/run_primitive_collision_proxy.py --help
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
General form:
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
|
| 103 |
+
--mesh <mesh_path_relative_to_raw_asset_dir> \
|
| 104 |
+
--variant <variant_name> \
|
| 105 |
+
[proxy options] \
|
| 106 |
+
[MJCF options] \
|
| 107 |
+
[repository options]
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### Required argument
|
| 111 |
+
|
| 112 |
+
| Argument | Meaning |
|
| 113 |
+
| --- | --- |
|
| 114 |
+
| `raw_asset_dir` | Raw asset directory under `assets/<source>/raw/<asset_type>/<category>/<asset_id>/`. |
|
| 115 |
+
|
| 116 |
+
### Input selection
|
| 117 |
+
|
| 118 |
+
| Option | Default | Meaning |
|
| 119 |
+
| --- | --- | --- |
|
| 120 |
+
| `--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. |
|
| 121 |
+
| `--mesh-glob <glob>` | `visuals/rack1.obj` | Glob used when `--mesh` is omitted. Repeatable. |
|
| 122 |
+
|
| 123 |
+
The script currently parses OBJ geometry directly. Use OBJ input for this tool.
|
| 124 |
+
|
| 125 |
+
### Repository/output options
|
| 126 |
+
|
| 127 |
+
| Option | Default | Meaning |
|
| 128 |
+
| --- | --- | --- |
|
| 129 |
+
| `--variant <name>` | `primitive_boxes_v1` | Output suffix. The derived asset directory becomes `<source_asset_id>_<variant>`. |
|
| 130 |
+
| `--output-dir <path>` | canonical derived path | Optional explicit output directory for inspection. |
|
| 131 |
+
| `--overwrite` | false | Allow writing into an existing output directory. Use cautiously. |
|
| 132 |
+
| `--register-manifest` | false | Append the generated derived asset to `manifest/assets.jsonl`. Use only for outputs intended to be kept. |
|
| 133 |
+
|
| 134 |
+
### Proxy generation options
|
| 135 |
+
|
| 136 |
+
| Option | Default | Meaning |
|
| 137 |
+
| --- | --- | --- |
|
| 138 |
+
| `--name-prefix <prefix>` | `proxy` | Prefix for generated cuboid and MuJoCo geom names. |
|
| 139 |
+
| `--segment-length <float>` | `0.03` | Maximum segment length before splitting a connected component along its longest axis. Smaller values produce more/shorter boxes. |
|
| 140 |
+
| `--padding <float>` | `0.001` | Extra half-extent added to each generated cuboid. Larger values make collision more conservative. |
|
| 141 |
+
| `--min-half-extent <float>` | `0.0015` | Minimum half-extent per cuboid axis. Prevents zero-thickness boxes. |
|
| 142 |
+
| `--min-component-vertices <int>` | `4` | Discard connected components with fewer vertices. |
|
| 143 |
+
| `--min-segment-vertices <int>` | `2` | Discard split segments with fewer vertices. |
|
| 144 |
+
| `--allowed-contact-target X Y Z` | none | OBJ-local point used to mark nearby cuboids as allowed-contact. |
|
| 145 |
+
| `--allowed-contact-radius <float>` | `0.03` | Radius around allowed-contact target. Cuboids whose centers are inside this radius are marked as `allowed_contact`. |
|
| 146 |
+
|
| 147 |
+
The generated proxy categories are:
|
| 148 |
+
|
| 149 |
+
```text
|
| 150 |
+
forbidden # exported to MuJoCo and cuRobo
|
| 151 |
+
allowed_contact # exported to MuJoCo for review, omitted from cuRobo forbidden world
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
Use allowed-contact marking for task-specific regions where contact is expected or permitted. Do not treat it as a full physical validation.
|
| 155 |
+
|
| 156 |
+
### MJCF options
|
| 157 |
+
|
| 158 |
+
| Option | Default | Meaning |
|
| 159 |
+
| --- | --- | --- |
|
| 160 |
+
| `--class-name <name>` | `primitive_collision` | `class` attribute for generated `<geom>` entries. Empty string disables it. |
|
| 161 |
+
| `--rgba-forbidden "r g b a"` | `0.8 0.1 0.1 0.45` | RGBA for forbidden cuboids. |
|
| 162 |
+
| `--rgba-allowed "r g b a"` | `0.1 0.6 1 0.45` | RGBA for allowed-contact cuboids. |
|
| 163 |
+
| `--group <int>` | `0` | MuJoCo geom group. Empty string disables it. |
|
| 164 |
+
| `--contype <int>` | empty | MuJoCo contact type. Empty means use MuJoCo default. |
|
| 165 |
+
| `--conaffinity <int>` | empty | MuJoCo contact affinity. Empty means use MuJoCo default. |
|
| 166 |
+
|
| 167 |
+
Generated MJCF files:
|
| 168 |
+
|
| 169 |
+
```text
|
| 170 |
+
mjcf/primitive_geoms_include.xml # include inside the target body
|
| 171 |
+
mjcf/primitive_collision_include.xml # standalone wrapper for preview/convenience
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
Recommended integration:
|
| 175 |
+
|
| 176 |
+
```xml
|
| 177 |
+
<!-- inside the object body that should receive primitive collision geoms -->
|
| 178 |
+
<include file="path/to/mjcf/primitive_geoms_include.xml"/>
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
## Output files
|
| 182 |
+
|
| 183 |
+
### `proxy/primitive_collision_proxy.json`
|
| 184 |
+
|
| 185 |
+
Contains:
|
| 186 |
+
|
| 187 |
+
- format marker
|
| 188 |
+
- generation params
|
| 189 |
+
- source mesh stats
|
| 190 |
+
- cuboid list
|
| 191 |
+
- each cuboid's name, source mesh, category, position, half-size, full dimensions, component index, and segment index
|
| 192 |
+
|
| 193 |
+
### `logs/cuboids_summary.csv`
|
| 194 |
+
|
| 195 |
+
Tabular summary for inspection:
|
| 196 |
+
|
| 197 |
+
```text
|
| 198 |
+
name
|
| 199 |
+
source_mesh
|
| 200 |
+
category
|
| 201 |
+
component
|
| 202 |
+
segment
|
| 203 |
+
pos_x / pos_y / pos_z
|
| 204 |
+
size_x / size_y / size_z # MuJoCo half-size
|
| 205 |
+
dim_x / dim_y / dim_z # full dimensions
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
Use this file to identify boxes that are too long, too thick, or unexpectedly spanning a slot.
|
| 209 |
+
|
| 210 |
+
### `curobo/primitive_world.yml`
|
| 211 |
+
|
| 212 |
+
cuRobo cuboid fragment generated from `forbidden` cuboids only. `allowed_contact` cuboids are intentionally omitted.
|
| 213 |
+
|
| 214 |
+
### `REPORT.md`
|
| 215 |
+
|
| 216 |
+
Human-readable generation report with mesh stats, cuboid counts, largest cuboids, and a review checklist.
|
| 217 |
+
|
| 218 |
+
## Practical presets
|
| 219 |
+
|
| 220 |
+
Dishwasher rack first pass:
|
| 221 |
+
|
| 222 |
+
```bash
|
| 223 |
+
python scripts/run_primitive_collision_proxy.py \
|
| 224 |
+
assets/robocasa/raw/fixtures/dishwashers/Dishwasher031 \
|
| 225 |
+
--mesh visuals/rack1.obj \
|
| 226 |
+
--variant rack1_primitive_boxes_v1 \
|
| 227 |
+
--segment-length 0.03 \
|
| 228 |
+
--padding 0.001 \
|
| 229 |
+
--min-half-extent 0.0015
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
Finer boxes:
|
| 233 |
+
|
| 234 |
+
```bash
|
| 235 |
+
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
|
| 236 |
+
--mesh visuals/rack1.obj \
|
| 237 |
+
--variant rack1_primitive_boxes_fine_v1 \
|
| 238 |
+
--segment-length 0.015 \
|
| 239 |
+
--padding 0.0005 \
|
| 240 |
+
--min-half-extent 0.001
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
Coarser boxes:
|
| 244 |
+
|
| 245 |
+
```bash
|
| 246 |
+
python scripts/run_primitive_collision_proxy.py <raw_asset_dir> \
|
| 247 |
+
--mesh visuals/rack1.obj \
|
| 248 |
+
--variant rack1_primitive_boxes_coarse_v1 \
|
| 249 |
+
--segment-length 0.06 \
|
| 250 |
+
--padding 0.0015 \
|
| 251 |
+
--min-half-extent 0.002
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
## Review checklist
|
| 255 |
+
|
| 256 |
+
Before registering primitive proxies in `manifest/assets.jsonl`:
|
| 257 |
+
|
| 258 |
+
- Open or render `mjcf/primitive_geoms_include.xml` with the visual mesh.
|
| 259 |
+
- Confirm boxes do not bridge functional rack slots.
|
| 260 |
+
- Confirm boxes are not much thicker than the intended rod/wire collision margin.
|
| 261 |
+
- Confirm the chosen `segment-length` is not creating too many boxes for MuJoCo or cuRobo.
|
| 262 |
+
- Confirm allowed-contact cuboids, if used, are task-specific and documented.
|
| 263 |
+
- Run:
|
| 264 |
+
|
| 265 |
+
```bash
|
| 266 |
+
python scripts/validate_asset.py assets/<source>/derived/primitive_collision_proxies/<category>/<asset_id>
|
| 267 |
+
python scripts/validate_asset.py --all
|
| 268 |
+
```
|
| 269 |
+
|
| 270 |
+
## Manifest rule
|
| 271 |
+
|
| 272 |
+
Primitive proxy results are real derived assets and must be indexed in:
|
| 273 |
+
|
| 274 |
+
```text
|
| 275 |
+
manifest/assets.jsonl
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
Only register reviewed outputs that should be reused. Temporary trials should not be listed in the manifest.
|