Skip to content

Extended contact visualizations - #3615

Open
Guirec-Maloisel wants to merge 4 commits into
newton-physics:mainfrom
disneyresearch:dev/gm/contact_visualizations
Open

Extended contact visualizations#3615
Guirec-Maloisel wants to merge 4 commits into
newton-physics:mainfrom
disneyresearch:dev/gm/contact_visualizations

Conversation

@Guirec-Maloisel

@Guirec-Maloisel Guirec-Maloisel commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

This refines the (rigid) contact visualization options in the newton viewer, allowing to visualize the contact force, as well as the contact mode (open / sliding / sticking, using a color-coded disk in the tangential plane), on top of the contact normal (as per the current viewer).

The disk color (contact mode) and force visualization both require access to the contact force (e.g. through calling builder.request_contact_attributes("force")), but will default to black (open contact) and no force vector if not available.

Checklist

  • New or existing tests cover these changes
  • The documentation is up to date with these changes
  • CHANGELOG.md has been updated (if user-facing change)

Test plan

This has been incorporated for a while in my local branch for validating contact modeling and comparing solvers, so it has been indirectly tested there. Not sure what the policy is for unit testing the viewer outside of this (apart from the reviewers trying it out on the newton examples).

Summary by CodeRabbit

  • New Features

    • Added separate visualization controls for contact normals, contact modes, and contact forces.
    • Contact modes are shown with color-coded disks for open, sticking, and sliding behavior.
    • Contact forces appear as directional arrows when force data is available.
    • Added controls for contact scale, force scale, and arrow thickness.
    • Visualization scales adapt automatically to the model while preserving manual adjustments.
  • Documentation

    • Updated the changelog with details about the refined contact visualizations.

@Guirec-Maloisel Guirec-Maloisel self-assigned this Jul 23, 2026
@Guirec-Maloisel
Guirec-Maloisel requested a review from a team as a code owner July 23, 2026 13:53
@Guirec-Maloisel Guirec-Maloisel changed the title Dev/gm/contact visualizations Extended contact visualizations Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 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 Plus

Run ID: 2a5afe8c-1487-4575-9702-e2021cc3d160

📥 Commits

Reviewing files that changed from the base of the PR and between b0260f3 and 9b2c582.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • newton/_src/solvers/kamino/_src/utils/sim/viewer.py
  • newton/_src/viewer/kernels.py
  • newton/_src/viewer/viewer.py
  • newton/_src/viewer/viewer_gui.py
  • newton/examples/kamino/example_kamino_basic_dr_testmech.py
  • newton/examples/kamino/example_kamino_basic_fourbar.py
  • newton/examples/kamino/example_kamino_basic_heterogeneous.py
  • newton/examples/kamino/example_kamino_robot_anymal_d.py
  • newton/examples/kamino/example_kamino_robot_dr_legs.py
🚧 Files skipped from review as they are similar to previous changes (10)
  • newton/examples/kamino/example_kamino_robot_dr_legs.py
  • newton/examples/kamino/example_kamino_basic_heterogeneous.py
  • newton/examples/kamino/example_kamino_basic_dr_testmech.py
  • newton/_src/viewer/viewer_gui.py
  • newton/examples/kamino/example_kamino_basic_fourbar.py
  • CHANGELOG.md
  • newton/_src/solvers/kamino/_src/utils/sim/viewer.py
  • newton/examples/kamino/example_kamino_robot_anymal_d.py
  • newton/_src/viewer/kernels.py
  • newton/_src/viewer/viewer.py

📝 Walkthrough

Walkthrough

The viewer now renders contact normals, mode-colored disks, and force arrows through separate controls and namespaces. Contact scales adapt to model dimensions and dynamics. Kamino examples request force contact attributes.

Changes

Contact visualization

Layer / File(s) Summary
Contact geometry kernels
newton/_src/viewer/kernels.py
Adds normal-aligned contact disks, open/stick/slip colors, and force-arrow geometry with filtering for inactive, self-contact, and hidden-world entries.
Viewer integration and controls
newton/_src/viewer/viewer.py, newton/_src/viewer/viewer_gui.py, newton/_src/solvers/.../viewer.py, CHANGELOG.md
Adds independent visualization paths, adaptive scales, GUI controls, corrected force-buffer initialization, and a changelog entry.
Contact force data provisioning
newton/examples/kamino/*
Requests "force" contact attributes in the affected Kamino model builders.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ViewerBase
  participant ContactKernels
  participant ContactNamespaces
  ViewerBase->>ContactKernels: compute contact normals, modes, and forces
  ContactKernels-->>ViewerBase: geometry buffers and colors
  ViewerBase->>ContactNamespaces: log normals, modes, and forces independently
Loading

Possibly related PRs

Suggested reviewers: eric-heiden

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.19% 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 clearly and concisely describes the main change: expanded contact visualization features.
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.
✨ 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.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 50 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
newton/_src/viewer/viewer.py 56.81% 38 Missing ⚠️
newton/_src/viewer/viewer_gui.py 0.00% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

@eric-heiden

Copy link
Copy Markdown
Member

Thanks, looks like a useful feature! There is some z-fighting in the black discs for the open contact mode. Perhaps you want to just scale them slightly larger to prevent this flickering?

Recording.2026-07-24.165229.mp4

Comment thread newton/_src/viewer/kernels.py
@coderabbitai coderabbitai Bot mentioned this pull request Jul 30, 2026
3 tasks
@Guirec-Maloisel
Guirec-Maloisel force-pushed the dev/gm/contact_visualizations branch from af9f29b to 9f7c293 Compare August 4, 2026 14:40
@Guirec-Maloisel

Guirec-Maloisel commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@eric-heiden thanks for reviewing! I've pushed a fix that addresses the z-fighting as suggested (sorry for not looking again into this earlier, I was on vacation).

2026-08-04.16-59-11.mp4

eric-heiden
eric-heiden previously approved these changes Aug 5, 2026

@eric-heiden eric-heiden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing the rendering! @Guirec-Maloisel can you fix the merge conflict? Then we can merge.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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.

2 participants