Placement_Assets / docs /primitive_collision_proxy_spec.md
yuchi233's picture
Upload docs/primitive_collision_proxy_spec.md with huggingface_hub
504e487 verified
|
Raw
History Blame Contribute Delete
9.45 kB
# 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.