-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Newton] Refresh FK before ray-cast sensor reads #7523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed Newton ray-caster updates reading stale carrier poses after joint or root state writes. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2658,10 +2658,10 @@ def get_state_0(cls) -> State: | |
|
|
||
| @classmethod | ||
| def get_state(cls, scene_data_provider: SceneDataProvider | None = None) -> State: | ||
| """Get the current Newton state for visualization. | ||
| """Get the current Newton state with derived transforms refreshed. | ||
|
|
||
| Use this method from visualizers/renderers/video recorders that need a | ||
| backend-agnostic Newton ``State``. When the sim backend is PhysX this | ||
| Use this method from sensors, visualizers, renderers, and video recorders that need | ||
| a backend-agnostic Newton ``State``. When the sim backend is PhysX this | ||
| refreshes the shadow ``_state_0.body_q`` from the live PhysX scene via | ||
| :meth:`update_visualization_state` before returning, so callers never | ||
| observe stale transforms. Under the Newton sim backend, pending | ||
|
|
@@ -2708,12 +2708,13 @@ def _unregister_sensor_task(cls, name: str) -> None: | |
|
|
||
| @classmethod | ||
| def _update_sensor_tasks(cls, *names: str) -> None: | ||
| """Refit the shape and particle BVHs and run the requested scene-query tasks.""" | ||
| """Refresh derived state, refit the BVHs, and run the requested scene-query tasks.""" | ||
| for name in names: | ||
| if name not in cls._sensor_tasks: | ||
| raise KeyError(f"Newton sensor task '{name}' is not registered.") | ||
|
|
||
| state = cls.get_state_0() | ||
| # Resolve pending FK before entering the graph-capturable sensor pipeline. | ||
| state = cls.get_state() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Warning · Implementation — Resolved FK does not invalidate BVH cache
|
||
| if state is not cls._sensor_state: | ||
| cls._sensor_state = state | ||
| cls._sensor_state_dirty = True | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every sensor-task update now calls
get_state(), whose Newton path runsforward()and marks sensor state dirty even when no FK work is pending. Repeated ray-caster or renderer reads without an intervening state change therefore rerun the shared shape and particle BVH refits, adding avoidable work for every consumer read.Knowledge Base Used: Newton backend
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!