Skip to content

Add targeted checkerboard material utility - #3216

Merged
eric-heiden merged 2 commits into
newton-physics:mainfrom
eric-heiden:eric/tiled-camera-checkerboard-material
Jun 23, 2026
Merged

Add targeted checkerboard material utility#3216
eric-heiden merged 2 commits into
newton-physics:mainfrom
eric-heiden:eric/tiled-camera-checkerboard-material

Conversation

@eric-heiden

@eric-heiden eric-heiden commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Add SensorTiledCamera.utils.assign_checkerboard_material(shape_indices=...) so checkerboard material can be applied to explicit shapes only.
  • Deprecate assign_checkerboard_material_to_all_shapes() as of Newton 1.4 and route legacy all-shapes behavior through the new API.
  • Update sensor_tiled_camera so only the ground plane receives the checkerboard texture, preserving the Franka robot's imported visual materials.

Root Cause

The tiled camera example used the old all-shapes checkerboard helper as a stand-in for ViewerGL's checker floor. That helper also textured the robot, so parts of the Franka rendered with checkerboard albedo instead of their imported visual colors.

Links: #3213

Validation

  • uv run python docs\generate_api.py
  • uv run -m newton.examples sensor_tiled_camera --viewer null --test --quiet --num-frames 1
  • $env:WARP_CACHE_PATH = Join-Path $env:TEMP 'warp-newton-checkerboard-pr-cache'; uv run --extra dev -m unittest newton.tests.test_sensor_tiled_camera newton.tests.test_sensor_tiled_camera_heightfield
  • uvx ruff check CHANGELOG.md newton\_src\sensors\warp_raytrace\utils.py newton\_src\sensors\sensor_tiled_camera.py newton\examples\sensors\example_sensor_tiled_camera.py newton\tests\test_sensor_tiled_camera.py newton\tests\test_sensor_tiled_camera_heightfield.py
  • uvx ruff format --check newton\_src\sensors\warp_raytrace\utils.py newton\_src\sensors\sensor_tiled_camera.py newton\examples\sensors\example_sensor_tiled_camera.py newton\tests\test_sensor_tiled_camera.py newton\tests\test_sensor_tiled_camera_heightfield.py
  • uvx pre-commit run -a

Summary by CodeRabbit

  • New Features

    • Added selective checkerboard texture application—users can now apply checkerboard materials to specific shapes rather than all shapes.
  • Deprecations

    • Deprecated the method that applies checkerboard textures to all shapes. Use the new selective API instead.

Add a tiled-camera utility that applies the checkerboard texture only to explicit shape indices and deprecate the previous all-shapes helper.

Update the tiled camera example to checker only the ground plane so imported robot visual materials remain visible, and cover the API migration in tests.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: ac17a722-b9ca-478f-91b2-cb511350b9d9

📥 Commits

Reviewing files that changed from the base of the PR and between edb608e and 6f81b8a.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • newton/_src/sensors/warp_raytrace/utils.py
  • newton/tests/test_sensor_tiled_camera.py
💤 Files with no reviewable changes (1)
  • newton/_src/sensors/warp_raytrace/utils.py
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • newton/tests/test_sensor_tiled_camera.py

📝 Walkthrough

Walkthrough

A new Utils.assign_checkerboard_material(shape_indices=...) method is added that applies checkerboard textures only to explicitly selected shapes. The previous assign_checkerboard_material_to_all_shapes() is deprecated and now delegates to the new method. The tiled camera example is updated to track robot and ground shape indices separately, and tests are added for the new API and deprecation behavior.

Changes

Shape-selective checkerboard material

Layer / File(s) Summary
New assign_checkerboard_material API in Utils
newton/_src/sensors/warp_raytrace/utils.py
Adds warnings and Sequence imports; introduces assign_checkerboard_material(shape_indices=...) with bounds validation and selective texture id assignment (0 for selected, -1 for others); replaces assign_checkerboard_material_to_all_shapes body with a DeprecationWarning emitter that delegates to the new method.
Example shape index tracking and selective assignment
newton/examples/sensors/example_sensor_tiled_camera.py
Declares robot_shape_indices in __init__, records exact shape index range from the robot sub-builder, stores robot_shape_indices and ground_shape_indices as NumPy arrays, narrows checkerboard assignment to ground shapes only, and adds test_final pixel-level assertions separating ground checker swatches from robot pixels.
Tests, heightfield test update, and changelog
newton/tests/test_sensor_tiled_camera.py, newton/tests/test_sensor_tiled_camera_heightfield.py, CHANGELOG.md
Adds TypeError test for missing keyword args; updates golden image test to use assign_checkerboard_material(shape_indices=np.arange(...)) ; adds CUDA-skipped deprecation warning test; changes heightfield test to target shape index [0]; documents new API and deprecation in changelog.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • newton-physics/newton#3088: Touches test_sensor_tiled_camera_heightfield.py's test_renders_flat_heightfield_from_above material setup, the same test updated in this PR.
  • newton-physics/newton#3168: Directly related — removes the deprecated assign_checkerboard_material_to_all_shapes surface introduced in this PR's deprecation path.

Suggested reviewers

  • mzamoramora-nvidia
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add targeted checkerboard material utility' directly summarizes the main change: introducing a new targeted utility for applying checkerboard materials to specific shapes instead of all shapes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@newton/_src/sensors/warp_raytrace/utils.py`:
- Around line 865-882: The function does not validate the `resolution` and
`checker_size` parameters before using them in the checkerboard generation logic
at line 881. Add validation checks immediately after the shape_indices
validation to ensure both `resolution` and `checker_size` are positive integers
(greater than 0). If either parameter is invalid, raise a clear ValueError that
explains the constraint. Place these checks before the checkerboard calculation
that uses `np.arange(resolution) // checker_size` to prevent ZeroDivisionError
and invalid texture generation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 041566a6-0a71-4835-88eb-e918cb99108e

📥 Commits

Reviewing files that changed from the base of the PR and between cf8e1ad and edb608e.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • newton/_src/sensors/sensor_tiled_camera.py
  • newton/_src/sensors/warp_raytrace/utils.py
  • newton/examples/sensors/example_sensor_tiled_camera.py
  • newton/tests/test_sensor_tiled_camera.py
  • newton/tests/test_sensor_tiled_camera_heightfield.py

Comment thread newton/_src/sensors/warp_raytrace/utils.py
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
newton/_src/sensors/warp_raytrace/utils.py 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

daniela-hase
daniela-hase previously approved these changes Jun 23, 2026
Resolve tiled camera sensor conflicts after main removed legacy compatibility helpers. Keep the new selective checkerboard utility and update the PR on top of current main.
@eric-heiden
eric-heiden added this pull request to the merge queue Jun 23, 2026
Merged via the queue into newton-physics:main with commit f4f7f5d Jun 23, 2026
25 checks passed
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.

[BUG] SensorTiledCamera colors/lighting seem off in example script newton.examples sensor_tiled_camera

2 participants