Repository navigation
Turn a calibrated GenSim object to the heading its mask shows - #1336
Yuan-Xinyi wants to merge 1 commit into
Conversation
Source calibration fitted a uniform scale and tabletop position at the generated heading only. When that heading is wrong the object's projection cannot take the shape of its mask, and the least-squares scale is an arbitrary compromise: a microphone generated across the view but photographed pointing away from the camera came out at 0.44 scale. An object whose bounding box cannot be matched within 10% at the generated heading is now turned about the vertical to the heading whose projected outline overlaps the mask most. Objects that already match are unchanged. One that no heading matches keeps its generated heading, is flagged in reference_layout.json and raises a warning. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Confidence Score: 4/5
[Medium impact] The change affects scene setup only when source calibration is used. The PR appears safe to merge, with a non-blocking gap in tests for asymmetric objects. Findings
Fix with agent prompt### Issue 1
tests/gen_sim/test_source_calibration.py:178
This test uses a box and accepts either 90° or 270°, so it cannot check whether `_mask_overlap` selects the right half turn. A change that reverses asymmetric objects could still pass. Add an asymmetric mesh whose competing headings both pass the box check, then assert that the heading with better overlap wins.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThis PR adds a heading search when a generated object's fitted box differs from its mask by more than 10%.
Intentional limits acknowledged by Yuan-Xinyi: headings that already pass the box check stay unchanged, and wrong resting poses are only flagged because vertical turns cannot fix them.
|
| (fit,) = report["objects"] | ||
| # Without the turn the wide box is squeezed into the tall mask at a | ||
| # fraction of its size; turned, it keeps the scene's one-third scale. | ||
| assert fit["heading_offset_deg"] in (90.0, 270.0) |
There was a problem hiding this comment.
Opposite headings remain unchecked
This test uses a box and accepts either 90° or 270°, so it cannot check whether _mask_overlap selects the right half turn. A change that reverses asymmetric objects could still pass. Add an asymmetric mesh whose competing headings both pass the box check, then assert that the heading with better overlap wins.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/gen_sim/test_source_calibration.py
Line: 178
Comment:
**Opposite headings remain unchecked**
This test uses a box and accepts either 90° or 270°, so it cannot check whether `_mask_overlap` selects the right half turn. A change that reverses asymmetric objects could still pass. Add an asymmetric mesh whose competing headings both pass the box check, then assert that the heading with better overlap wins.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Description
GenSim source calibration could give a tabletop object an arbitrary size when the generated scene had the object at the wrong heading. This PR turns such an object about the vertical to the heading its image mask shows, and flags the objects no heading can match. Objects that already match are untouched.
Related to #1248 (B1, "Object yaw is not reproduced"). The wrong heading itself comes from scene generation and is not addressed here; this PR stops the calibration step from turning a wrong heading into a wrong size as well.
The problem
handover_mic: the source frame shows a microphone lying on the table, pointing away from the camera.reference_layout.jsonrecordedrelative_extent_error: 0.83for it. Nothing acted on that number.Cause
_fit_objectfits one uniform scale and a tabletop position so that the projected bounding box matches the mask's bounding box, with the mesh fixed at its generated heading. The mask of the microphone is 48 × 144 px (narrow and tall). Lying across the view, the mesh projects wide and short, so no scale can match both sides; least squares returns a compromise.calibrate_sceneapplies that scale whatever the residual is.Change
RuntimeWarning.reference_layout.jsongainsheading_offset_degandmatches_maskper object.Measured before and after
The calibration was recomputed offline for the 87 tabletop rigid objects of 50 scenes generated from RoboTwin first frames (existing scene exports and masks; no scene was regenerated).
beat_block_hammer(91%) and the bottle ofshake_bottle(21%). Why they do not match was not investigated.Green is the object's mask in the source frame; orange and blue are the projected outline of the calibrated object before and after.
handover_mic/ micmove_stapler_pad/ black_padmove_stapler_pad/ staplergrab_roller/ rolling_pinscan_object/ scannermove_playingcard_away/ boxNot covered
Type of change
Screenshots
See "Measured before and after" above.
Validation
pytest tests/gen_sim/test_source_calibration.py: 8 passed. Two cases are new: an object generated across the view and photographed along it is turned and keeps the scene's scale; an object generated standing and photographed lying is flagged and warned about. The six existing cases cover the unchanged path.black --checkon the changed files.tests/gen_sim/test_workflow.pyhas 38 failures in my local environment with and without this change (a robot-registry mapping of the local install); none involve this module.Checklist
black .command to format the code base.embodichain/gen_sim/README.mddescribes the new behaviour; the gen-sim agent context only names the option and needs no change.)python docs/scripts/check_api_docs.py), if applicable (no public API changes; the module exports nothing).🤖 Generated with Claude Code