Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ci:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.10
rev: v0.15.9
hooks:
# Run the linter.
- id: ruff
Expand All @@ -26,12 +26,12 @@ repos:
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.9.21
rev: 0.11.3
hooks:
# Update the uv lockfile
- id: uv-lock
- repo: https://github.com/crate-ci/typos
rev: v1.42.0
rev: v1
hooks:
- id: typos
args: []
Expand Down
2 changes: 1 addition & 1 deletion docs/print_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_symbols(mod_name: str):
else:
children.append(name)

return (mod_name.split(".")[-1], children)
return (mod_name.rsplit(".", maxsplit=1)[-1], children)


def print_symbols(sym_dict, indent=0):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ def test_final(self):
self.model,
self.state_0,
"body velocities are small",
lambda q, qd: max(abs(qd))
< 0.25, # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2
lambda q, qd: (
max(abs(qd)) < 0.25
), # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2
)


Expand Down
5 changes: 3 additions & 2 deletions newton/_src/solvers/kamino/examples/newton/example_dr_legs.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def test_final(self):
self.model,
self.state_0,
"body velocities are small",
lambda q, qd: max(abs(qd))
< 0.25, # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2
lambda q, qd: (
max(abs(qd)) < 0.25
), # Relaxed from 0.1 - unified pipeline has residual velocities up to ~0.2
)


Expand Down
8 changes: 3 additions & 5 deletions newton/_src/usd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,11 +1718,9 @@ def _get_bound_material(target_prim: Usd.Prim) -> UsdShade.Material | None:
if not rels:
return None
rels.sort(
key=lambda rel: 0
if rel.GetName() == "material:binding"
else 1
if rel.GetName() == "material:binding:preview"
else 2
key=lambda rel: (
0 if rel.GetName() == "material:binding" else 1 if rel.GetName() == "material:binding:preview" else 2
)
)
for rel in rels:
targets = rel.GetTargets()
Expand Down
2 changes: 1 addition & 1 deletion newton/_src/utils/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def get_name_from_label(label: str):
Returns:
The final path component of the label.
"""
return label.split("/")[-1]
return label.rsplit("/", maxsplit=1)[-1]


def find_matching_ids(pattern: str, labels: list[str], world_ids, world_count: int):
Expand Down
6 changes: 4 additions & 2 deletions newton/examples/basic/example_basic_joints.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ def test_post_step(self):
self.model,
self.state_0,
"linear motion on axis",
lambda q, qd: wp.length(abs(wp.cross(wp.spatial_top(qd), wp.vec3(0.0, 0.0, 1.0)))) < 1e-5
and wp.length(wp.spatial_bottom(qd)) < 1e-5,
lambda q, qd: (
wp.length(abs(wp.cross(wp.spatial_top(qd), wp.vec3(0.0, 0.0, 1.0)))) < 1e-5
and wp.length(wp.spatial_bottom(qd)) < 1e-5
),
indices=[self.model.body_label.index("b_prismatic")],
)

Expand Down
16 changes: 9 additions & 7 deletions newton/examples/basic/example_basic_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ def test_final(self):
self.model,
self.state_0,
"cylinder at rest pose",
lambda q, qd: abs(q[0] - cylinder_q[0]) < 0.01
and abs(q[1] - cylinder_q[1]) < 0.01
and abs(q[2] - cylinder_q[2]) < 1e-4
and abs(q[3] - cylinder_q[3]) < 1e-4
and abs(q[4] - cylinder_q[4]) < 1e-4
and abs(q[5] - cylinder_q[5]) < 1e-4
and abs(q[6] - cylinder_q[6]) < 1e-4,
lambda q, qd: (
abs(q[0] - cylinder_q[0]) < 0.01
and abs(q[1] - cylinder_q[1]) < 0.01
and abs(q[2] - cylinder_q[2]) < 1e-4
and abs(q[3] - cylinder_q[3]) < 1e-4
and abs(q[4] - cylinder_q[4]) < 1e-4
and abs(q[5] - cylinder_q[5]) < 1e-4
and abs(q[6] - cylinder_q[6]) < 1e-4
),
[3],
)
self.box_pos[2] = 0.25
Expand Down
5 changes: 3 additions & 2 deletions newton/examples/robot/example_robot_anymal_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ def test_final(self):
self.model,
self.state_0,
"body velocities are small",
lambda q, qd: max(abs(qd))
< 0.25, # Relaxed from 0.1 - collision pipeline has residual velocities up to ~0.2
lambda q, qd: (
max(abs(qd)) < 0.25
), # Relaxed from 0.1 - collision pipeline has residual velocities up to ~0.2
)

@staticmethod
Expand Down
35 changes: 19 additions & 16 deletions newton/examples/robot/example_robot_cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,37 @@ def test_final(self):
self.model,
self.state_0,
"cart only moves along y direction",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and wp.length_sq(wp.spatial_bottom(qd)) == 0.0,
lambda q, qd: (
qd[0] == 0.0 and abs(qd[1]) > 0.05 and qd[2] == 0.0 and wp.length_sq(wp.spatial_bottom(qd)) == 0.0
),
indices=[i * num_bodies_per_world for i in range(self.world_count)],
)
newton.examples.test_body_state(
self.model,
self.state_0,
"pole1 only has y-axis linear velocity and x-axis angular velocity",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and abs(qd[3]) > 0.3
and qd[4] == 0.0
and qd[5] == 0.0,
lambda q, qd: (
qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and abs(qd[3]) > 0.3
and qd[4] == 0.0
and qd[5] == 0.0
),
indices=[i * num_bodies_per_world + 1 for i in range(self.world_count)],
)
newton.examples.test_body_state(
self.model,
self.state_0,
"pole2 only has yz-plane linear velocity and x-axis angular velocity",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and abs(qd[2]) > 0.05
and abs(qd[3]) > 0.2
and qd[4] == 0.0
and qd[5] == 0.0,
lambda q, qd: (
qd[0] == 0.0
and abs(qd[1]) > 0.05
and abs(qd[2]) > 0.05
and abs(qd[3]) > 0.2
and qd[4] == 0.0
and qd[5] == 0.0
),
indices=[i * num_bodies_per_world + 2 for i in range(self.world_count)],
)
qd = self.state_0.body_qd.numpy()
Expand Down
5 changes: 3 additions & 2 deletions newton/examples/robot/example_robot_g1.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ def test_final(self):
self.model,
self.state_0,
"all body velocities are small",
lambda q, qd: max(abs(qd))
< 0.015, # Relaxed from 0.005 - G1 has higher residual velocities with collision pipeline
lambda q, qd: (
max(abs(qd)) < 0.015
), # Relaxed from 0.005 - G1 has higher residual velocities with collision pipeline
)

@staticmethod
Expand Down
35 changes: 19 additions & 16 deletions newton/examples/selection/example_selection_cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,34 +185,37 @@ def test_final(self):
self.model,
self.state_0,
"cart only moves along y direction",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and wp.length_sq(wp.spatial_bottom(qd)) == 0.0,
lambda q, qd: (
qd[0] == 0.0 and abs(qd[1]) > 0.05 and qd[2] == 0.0 and wp.length_sq(wp.spatial_bottom(qd)) == 0.0
),
indices=[i * num_bodies_per_world for i in range(self.world_count)],
)
newton.examples.test_body_state(
self.model,
self.state_0,
"pole1 only has y-axis linear velocity and x-axis angular velocity",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and abs(qd[3]) > 0.3
and qd[4] == 0.0
and qd[5] == 0.0,
lambda q, qd: (
qd[0] == 0.0
and abs(qd[1]) > 0.05
and qd[2] == 0.0
and abs(qd[3]) > 0.3
and qd[4] == 0.0
and qd[5] == 0.0
),
indices=[i * num_bodies_per_world + 1 for i in range(self.world_count)],
)
newton.examples.test_body_state(
self.model,
self.state_0,
"pole2 only has yz-plane linear velocity and x-axis angular velocity",
lambda q, qd: qd[0] == 0.0
and abs(qd[1]) > 0.05
and abs(qd[2]) > 0.05
and abs(qd[3]) > 0.2
and qd[4] == 0.0
and qd[5] == 0.0,
lambda q, qd: (
qd[0] == 0.0
and abs(qd[1]) > 0.05
and abs(qd[2]) > 0.05
and abs(qd[3]) > 0.2
and qd[4] == 0.0
and qd[5] == 0.0
),
indices=[i * num_bodies_per_world + 2 for i in range(self.world_count)],
)

Expand Down
Loading