Fix Newton rigid object root state writers#6004
Conversation
Greptile SummaryThis PR fixes three deprecated root-state writer wrappers in the Newton
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted correction that makes the three deprecated wrappers callable without raising a TypeError. All four helper methods use keyword-only signatures (* separator), so the positional calls in the old code would have raised TypeError on any invocation. The fix correctly threads the tensor slices through as named arguments. No logic is changed, and there are no other code paths affected by these six one-line edits. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Wrapper as Deprecated Wrapper
participant Helper as Keyword-Only Helper
Caller->>Wrapper: write_root_state_to_sim(root_state, env_ids)
Note over Wrapper: Slices root_state[:, :7] as pose
Note over Wrapper: Slices root_state[:, 7:] as velocity
Wrapper->>Helper: "write_root_link_pose_to_sim_index(root_pose=pose, env_ids=env_ids)"
Wrapper->>Helper: "write_root_com_velocity_to_sim_index(root_velocity=velocity, env_ids=env_ids)"
Note over Wrapper,Helper: Before fix: positional args raised TypeError
Note over Wrapper,Helper: After fix: keyword args dispatch correctly
Reviews (1): Last reviewed commit: "Fix Newton rigid object root state write..." | Re-trigger Greptile |
There was a problem hiding this comment.
Review Summary
Verdict: ✅ Clean, minimal bugfix — ready to merge
This PR correctly fixes a TypeError that occurs when the deprecated root state writer wrappers (write_root_state_to_sim, write_root_com_state_to_sim, write_root_link_state_to_sim) call the keyword-only helper methods without using explicit keyword arguments.
Analysis
Root Cause: The Newton backend's helper methods (write_root_link_pose_to_sim_index, write_root_com_pose_to_sim_index, write_root_com_velocity_to_sim_index, write_root_link_velocity_to_sim_index) all enforce keyword-only parameters via the * separator in their signatures:
def write_root_link_pose_to_sim_index(self, *, root_pose: ..., env_ids: ...) -> None:The deprecated wrappers were passing root_state[:, :7] and root_state[:, 7:] as positional arguments, which Python rejects with TypeError: takes 1 positional argument but 2 positional arguments were given.
Fix correctness: Each wrapper now passes the tensor slices as the correct keyword argument:
- Pose calls →
root_pose=root_state[:, :7] - Velocity calls →
root_velocity=root_state[:, 7:]
The keyword names match the helper signatures exactly across all three wrappers.
Findings
| # | Severity | Finding |
|---|---|---|
| 1 | 💡 info | The changelog fragment correctly documents the fix under Fixed using towncrier RST format. |
| 2 | 💡 info | CI checks (pre-commit, license-check, build-wheel, changelog fragments) all pass. Installation tests are still pending but unrelated to this code change. |
| 3 | The PR description notes tests were not run due to missing lazy_loader dependency locally. Since these are deprecated wrappers forwarding to well-tested helpers, runtime risk is low — but adding a unit test calling write_root_state_to_sim through the deprecated path would provide regression coverage if the helper signatures change again in the future. |
Summary of Changes
| File | Change |
|---|---|
rigid_object.py |
6 lines: positional → keyword arguments in 3 deprecated wrappers |
fix-rigid-object-state-writers.rst |
New changelog fragment (5 lines) |
No functional behavior change beyond fixing the crash. The fix is minimal, correctly scoped, and aligns the Newton backend with the keyword-only convention used across the codebase.
Summary
Tests
git diff --cached --checkbefore commitast.parselazy_loader