Repository navigation
Add OrientedBoundingBox - #1477
Merged
Merged
Conversation
zhx06
marked this pull request as ready for review
October 19, 2026 19:54
zhx06
requested review from
alexmillane,
cvolkcvolk,
peterd-NV,
qianl-nv,
viiik-inside and
xyao-nv
as code owners
October 19, 2026 19:54
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds batched
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]
Reviews (1) · Last reviewed commit: "introduce OBB" · Reviewed by Greptile |
alexmillane
reviewed
Oct 20, 2026
alexmillane
left a comment
Collaborator
There was a problem hiding this comment.
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.
Collaborator
|
/review |
zhx06
force-pushed
the
zxiao/feature/obb-geometry
branch
from
October 20, 2026 17:06
aaf7170 to
b1bebfc
Compare
zhx06
force-pushed
the
zxiao/feature/obb-geometry
branch
from
October 21, 2026 17:52
b1bebfc to
1ff97e5
Compare
Collaborator
|
/review |
alexmillane
approved these changes
Oct 22, 2026
Signed-off-by: zhx06 <[email protected]>
Signed-off-by: zhx06 <[email protected]>
Signed-off-by: zhx06 <[email protected]>
Signed-off-by: zhx06 <[email protected]>
zhx06
force-pushed
the
zxiao/feature/obb-geometry
branch
from
October 22, 2026 15:52
1ff97e5 to
69fb952
Compare
Contributor
|
The PR changed while this review was running. Please run Requested in this comment. |
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an abstract
BoundingBoxbase withOrientedBoundingBoxandAxisAlignedBoundingBoxas 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?
BoundingBoxis 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
marginis the required gap along the tested axes.projected_overlap_volume(other, margin): a differentiable overlap penalty for the placement solver.products.
unrotated scenes keep their results.
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 thecontaining frame and B is the box frame, so
x_axis_W = q_W_B * x_axis_B. It copies its inputs andreturns copies.
AxisAlignedBoundingBoxkeeps its imports, its mutable min/max storage and its empty and unboundedrange operations.
to_obb()andget_axis_aligned_bounds(), andoverlaps()now accepts oriented boxes.translated()now builds tuple offsets on the box's device. This fixes translating a CUDA AABB by atuple.
This PR adds geometry only. The solver loss and the
no_overlapvalidator keep their AABB paths, and theyswitch together in the follow-up collision PR.
projected_overlap_volumeis a pure geometry query, and the collisionPR only connects it to the solver. Defining it here settles the loss and its gradient before any solver
behavior changes.
axis and lifts objects off their support. Exact OBB intersection volume is not included either.
Limitations:
projected_overlap_volumecan stay positive for tilted boxes that only an edge-cross-edge axisseparates.
Usage example
Before:
After:
Both boxes must be in the same frame.
rotated_by_quat()still returns the enclosing AABB.Validation
test_bounding_box.pynow also covers OBBs. The new tests check:overlaps()on 256 random yaw-only pairs;test_bounding_box.pyfail. They covered SAT, transforms, thevolume, margins, AABB min/max paths, indexing and copy semantics.
test_relation_solver_background_collision.pycould not run locally: Isaac Sim segfaults at startup inthis container, with or without this change.