Skip to content

Add OrientedBoundingBox - #1477

Merged
zhx06 merged 4 commits into
mainfrom
zxiao/feature/obb-geometry
Oct 22, 2026
Merged

zhx06 merged 4 commits into
mainfrom
zxiao/feature/obb-geometry

Conversation

@zhx06

@zhx06 zhx06 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Add an abstract BoundingBox base with OrientedBoundingBox and AxisAlignedBoundingBox as siblings.
Add a separating-axis overlap test and a differentiable overlap-volume penalty that work on both.

Why this change?

Rotating an AABB produces an enclosing axis-aligned box. Two such boxes can overlap even when the rotated
boxes are separate, for example a long box rotated 45° next to a small box. Placement then pushes apart or
rejects objects that do not collide. An oriented bounding box (OBB) keeps the rotation and avoids this.

What changes?

BoundingBox is an abstract base. It implements the queries both box types share:

  • overlaps(other, margin): a strict 15-axis separating-axis test (SAT). Touching boxes do not overlap,
    and margin is the required gap along the tested axes.
  • projected_overlap_volume(other, margin): a differentiable overlap penalty for the placement solver.
    • It multiplies the interval overlaps along each box's face axes and returns the smaller of the two
      products.
    • For axis-aligned pairs it is the intersection volume, and it equals today's AABB no-overlap loss, so
      unrotated scenes keep their results.
    • For yaw-only boxes it is zero exactly when SAT finds no overlap.
  • transformed(t_A_W, q_A_W): maps boxes into another frame and keeps their rotation.
  • to_aabb(): returns the enclosing AABB.

The two box types own their storage:

  • OrientedBoundingBox(center_W, half_extents, rotation_W_B_xyzw) holds finite boxes. W is the
    containing frame and B is the box frame, so x_axis_W = q_W_B * x_axis_B. It copies its inputs and
    returns copies.
  • AxisAlignedBoundingBox keeps its imports, its mutable min/max storage and its empty and unbounded
    range operations.
    • It gains to_obb() and get_axis_aligned_bounds(), and overlaps() now accepts oriented boxes.
    • AABB pairs keep min/max code paths, so touching AABBs never overlap and have zero penalty.
    • translated() now builds tuple offsets on the box's device. This fixes translating a CUDA AABB by a
      tuple.

This PR adds geometry only. The solver loss and the no_overlap validator keep their AABB paths, and they
switch together in the follow-up collision PR.

  • Why the penalty is in this PR: projected_overlap_volume is a pure geometry query, and the collision
    PR only connects it to the solver. Defining it here settles the loss and its gradient before any solver
    behavior changes.
  • Why there is no penetration-depth query: as a solver loss, 3D SAT depth often picks the vertical
    axis and lifts objects off their support. Exact OBB intersection volume is not included either.

Limitations:

  • projected_overlap_volume can stay positive for tilted boxes that only an edge-cross-edge axis
    separates.
  • It is zero when this box has a zero-size dimension.
  • Mixed AABB/OBB queries rebuild centers from min/max, so float32 roundoff can flip touching verdicts.

Usage example

Before:

box = bounds.rotated_by_quat(q_A_W)
overlap = box.overlaps(other)

After:

box = bounds.transformed((0.0, 0.0, 0.0), q_A_W)
overlap = box.overlaps(other)
penalty = box.projected_overlap_volume(other, margin=0.01)

Both boxes must be in the same frame. rotated_by_quat() still returns the enclosing AABB.

Validation

  • test_bounding_box.py now also covers OBBs. The new tests check:
    • corners, transforms, batching, copy semantics and CUDA;
    • SAT separation on an edge-cross-edge axis, nearly parallel rods and margins;
    • the projected volume against independently projected corners, with gradients;
    • agreement between the projected volume and overlaps() on 256 random yaw-only pairs;
    • exactly zero volume for touching AABBs.
  • 319 tests in the bounding-box and placement suites pass on CPU and CUDA.
  • Every one of 17 injected bugs makes test_bounding_box.py fail. They covered SAT, transforms, the
    volume, margins, AABB min/max paths, indexing and copy semantics.
  • Pre-commit passes.
  • test_relation_solver_background_collision.py could not run locally: Isaac Sim segfaults at startup in
    this container, with or without this change.

@zhx06 zhx06 changed the title Add oriented bounding boxes Add OrientedBoundingBox Oct 19, 2026
@zhx06
zhx06 marked this pull request as ready for review October 19, 2026 19:54
@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds batched OrientedBoundingBox geometry and makes AxisAlignedBoundingBox its axis-aligned subclass.

  • Oriented boxes keep their shape through transforms and overlap queries.
  • Axis-aligned boxes keep their range behavior and join oriented queries.

Scope stated by zhx06: solver and placement-validator integration remains separate, and exact OBB intersection volume is not included.

No actionable issues were found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Query[Box overlap query] --> Types{Both boxes are AABBs?}
  Types -->|Yes| Intervals[Existing interval comparisons]
  Types -->|No| Geometry[Read current finite geometry]
  Geometry --> Aligned{Both rotations are fixed and axis-aligned?}
  Aligned -->|Yes| Three[Three-axis SAT]
  Aligned -->|No| Full[Fifteen-axis SAT]
Loading

Reviews (1) · Last reviewed commit: "introduce OBB" · Reviewed by Greptile

@alexmillane alexmillane left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass. Thanks for adding this. It's a good start.

The bigger comments are around:

  • Separation of AABB and OBB: Right now the OBB class is more complex because it has to support the AABB child. I would suggest we separate the classes more. See the comments in the design doc.
  • Frame conventions: I would suggest we try to adhere our conventions around frame notations more closely. It doesn't cost anything and it makes the transforms really clear.

Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
@cvolkcvolk

Copy link
Copy Markdown
Collaborator

/review

Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
Comment thread isaaclab_arena/utils/bounding_box.py Resolved
@zhx06
zhx06 force-pushed the zxiao/feature/obb-geometry branch from b1bebfc to 1ff97e5 Compare October 21, 2026 17:52
@alexmillane

Copy link
Copy Markdown
Collaborator

/review

@zhx06
zhx06 force-pushed the zxiao/feature/obb-geometry branch from 1ff97e5 to 69fb952 Compare October 22, 2026 15:52
@arena-review-bot

Copy link
Copy Markdown
Contributor

The PR changed while this review was running. Please run /review to retry.

Requested in this comment.

@zhx06
zhx06 merged commit 88f83c9 into main Oct 22, 2026
13 checks passed
zhx06 added a commit that referenced this pull request Oct 26, 2026
Use oriented bounding boxes for placement collision loss and validation.
Keep the existing interval calculation for axis-aligned boxes and batch
collision checks across candidates. This builds on `OrientedBoundingBox`
from #1477.

## Why this change?

Enclosing AABBs can overlap even when rotated objects are separate.
Placement previously penalized and rejected those layouts, although the
oriented geometry was available.

## What changes?

- Preserve each candidate's rotation and assigned object geometry
through solving, filtering, ranking and validation.
- **Loss for rotated boxes:** multiply the interval overlaps along each
box's face axes, and penalize the harmonic mean of the two volumes.
- It is zero exactly when a face axis separates the boxes by at least
`clearance_m`, and it equals the intersection volume for axis-aligned
pairs.
- When only one box's projections sit inside the other's, the other
box's volume still gives a gradient.
- `CachedOverlapVolumeUpperBound` caches the rotation-dependent terms
once per solve. Its `compute()` still returns the smaller volume, a true
upper bound.
- Validate with the separating-axis test.
- Keep the axis-aligned loss, directed gradients and existing mesh
checks. Use matching collision geometry for meshless background
obstacles.
- `RelationSolver` prepares pair routing for the box and mesh losses
once per solve.
- In the oriented loss, used when any collision box in a solve is
rotated, boxes thinner than 2 mm count as 2 mm thick. A flat object that
overlaps an obstacle therefore still has an overlap volume to reduce.

`collision_bboxes` stores oriented geometry once per batch, and each
candidate's enclosing AABBs are derived from it. Those AABBs remain
available for relation constraints and mesh proxies. For rotated rows
they can differ from the previous rotation code by up to about 2e-7 m.

`CollisionMode.BBOX` uses this automatically. Arbitrary-yaw results can
change, including existing clutter examples. Support containment and
clutter release initialization remain AABB-based; the existing
rotated-support and `On(overlap=True)` containment issues need a
separate correction.

## Results

The placement-success benchmark (#1497) ran every RoboLab and
KitchenBench spec on main and on this branch, with 50 layouts × 3 seeds
per spec.

| Setting | Suite | Layout success, main → this PR | Change (95%
interval) | Valid candidates, main → this PR | Change (95% interval) |
| --- | --- | ---: | ---: | ---: | ---: |
| Random yaw | RoboLab (38) | 64.6% → 76.4% | +10.9 to +12.3 pts | 36.2%
→ 64.6% | +28.0 to +28.7 pts |
| Random yaw | KitchenBench (20) | 31.8% → 33.1% | −0.1 to +2.6 pts |
8.2% → 8.5% | −0.1 to +0.7 pts |
| As authored | RoboLab (38) | 94.2% → 94.2% | −0.8 to +0.8 pts | 67.0%
→ 67.6% | +0.2 to +1.0 pts |
| As authored | KitchenBench (20) | 84.2% → 84.2% | −1.6 to +1.7 pts |
27.3% → 27.3% | −0.7 to +0.6 pts |

- **Random yaw:** 24 RoboLab tasks improve significantly after a Holm
adjustment, and none get worse. Bin and clutter tasks gain the most:
- `throw_away_snacks`: layout success goes from 28% to 100%, and valid
candidates from 3% to 68%;
  - `marker_in_mug`: valid candidates go from 7% to 82%.
- **KitchenBench is unchanged.** Random yaw also turns its robot away
from the fixture it is placed next to, and that dominates its failures,
so its random-yaw row says little about oriented boxes.
- **As authored:** no suite gets worse. Two RoboLab tasks improve,
`food_packing_1_boxes` and `food_packing_1_cans` (valid candidates 75% →
84%).
- **Why it improves:** the separating-axis test is exact for boxes, so
rotated layouts that enclosing AABBs falsely rejected now pass.
- **Exact quarter turns** are unchanged: positions, losses and verdicts
match main.

## Limitations

- **Tilted boxes:** the loss can penalize tilted boxes that the
separating-axis test finds separate.
- **Crossed rods:** when two long, thin boxes cross in an X, both
face-axis volumes are flat and the gradient is zero. In a probe with two
0.5 m rods at random yaw, 73.4% of candidates were valid, against 78.7%
with the enclosing-AABB loss under the same validator. A follow-up adds
an in-plane enclosing-box term to rotated pairs, which reached 84.5% in
the same probe.
- **Near-quarter yaws:** robot yaws such as `yaw_rad: 1.57` in
KitchenBench are not exact quarter turns, so those scenes take the
oriented path. Positions matched main in a probe; only the cost differs.

## Performance

- **Per solver iteration:** cost rises in rotated scenes, because each
directed pair stores a rotation per candidate. Caching the
rotation-dependent terms makes iterations 6–26% faster on CPU and lowers
peak memory by 16–22%, compared with recomputing them. The harmonic mean
adds 4–10% per iteration on CPU over the smaller volume.

  | Scene (objects × candidates) | CPU per iteration | Peak GPU memory |
  | --- | ---: | ---: |
  | 6 × 640 | 3.2 → 3.5 ms | 2.4 → 6.6 MiB |
  | 12 × 1024 | 7.3 → 9.8 ms | 15.2 → 44.4 MiB |
  | 25 × 1024 | 26.5 → 37.0 ms | 65.8 → 194.6 MiB |

- **Validation** is batched across candidates, which offsets much of the
solver cost.
- **Full-suite wall time** was noisy on a shared machine. Random-yaw
RoboLab went from 979 to 802 s. As authored, the median spec took 16%
longer.

These are placement measurements, not physics-acceptance rates.

## Validation

- **Benchmark:** the runs above compare main at `88f83c967a` with this
branch's final loss, before rebasing onto the Isaac Lab 3.0 update
(#1481). All 69 specs ran with no failures in both settings.
- **CI:** every check passes on `16e712dce3`, including both test jobs.
- **Local tests:**
- 392 placement, geometry and collision tests pass, including the
relation-solver visualization example;
- 24 simulator tests pass, covering clutter placement, embodiment
collision meshes, placement after build-time variations, and relation
placement from YAML;
  - pre-commit passes.
- **Stuck gradient:** a test places a yawed bar whose own-axis volume is
constant against a cube. It checks that the smaller volume has zero
gradient there, while the loss pushes the bar out.
- **Exact quarter turns:** candidate positions, losses and verdicts
match the AABB baseline exactly. The harmonic mean equals the exact
volume for axis-aligned pairs.
- **Zero thickness:** a test checks that a zero-thickness panel
overlapping a fixed block gets a loss and is pushed clear; it fails
without the 2 mm minimum.
- **Loss vs validator:** in 1.6M random pairs, yaw-only and tilted, at
margins 0 and 0.01, the validator accepted every layout the loss treats
as clear. The harmonic mean is zero exactly where the smaller volume is,
so this still holds.

---------

Signed-off-by: zhx06 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants