Skip to content
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

Fixes default joint pos when setting joint limits #1040

Merged
merged 8 commits into from
Oct 10, 2024
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.lab/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.24.13"
version = "0.24.14"

# Description
title = "Isaac Lab framework for Robot Learning"
Expand Down
9 changes: 9 additions & 0 deletions source/extensions/omni.isaac.lab/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
---------

0.24.14 (2024-09-25)
~~~~~~~~~~~~~~~~~~~~

Fixed
^^^^^

* Fixed potential issue where default joint positions can fall outside of the limits being set with Articulation's
``write_joint_limits_to_sim`` API.


0.24.13 (2024-09-08)
~~~~~~~~~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ def write_joint_limits_to_sim(
env_ids = env_ids[:, None]
# set into internal buffers
self._data.joint_limits[env_ids, joint_ids] = limits
# update default joint pos to stay within the new limits
Dhoeller19 marked this conversation as resolved.
Show resolved Hide resolved
self._data.default_joint_pos = torch.clamp(self._data.default_joint_pos, limits[..., 0], limits[..., 1])
Dhoeller19 marked this conversation as resolved.
Show resolved Hide resolved
# set into simulation
self.root_physx_view.set_dof_limits(self._data.joint_limits.cpu(), indices=physx_env_ids.cpu())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,48 @@ def test_out_of_range_default_joint_vel(self):
# Check if articulation is initialized
self.assertFalse(articulation._is_initialized)

def test_joint_limits(self):
"""Test write_joint_limits_to_sim API and when default pos falls outside of the new limits."""
for num_articulations in (1, 2):
for device in ("cuda:0", "cpu"):
with self.subTest(num_articulations=num_articulations, device=device):
with build_simulation_context(device=device, add_ground_plane=True, auto_add_lighting=True) as sim:
# Create articulation
articulation_cfg = generate_articulation_cfg(articulation_type="panda")
articulation, _ = generate_articulation(articulation_cfg, num_articulations, device)

# Play sim
sim.reset()
# Check if articulation is initialized
self.assertTrue(articulation._is_initialized)

# Get current default joint pos
default_joint_pos = articulation._data.default_joint_pos.clone()

# Set new joint limits
limits = torch.zeros(num_articulations, articulation.num_joints, 2, device=device)
limits[..., 0] = (
torch.rand(num_articulations, articulation.num_joints, device=device) + 5.0
) * -1.0
limits[..., 1] = torch.rand(num_articulations, articulation.num_joints, device=device) + 5.0
articulation.write_joint_limits_to_sim(limits)

# Check new limits are in place
torch.testing.assert_close(articulation._data.joint_limits, limits)
torch.testing.assert_close(articulation._data.default_joint_pos, default_joint_pos)

# Set new joint limits that invalidate default joint pos
limits = torch.zeros(num_articulations, articulation.num_joints, 2, device=device)
limits[..., 0] = torch.rand(num_articulations, articulation.num_joints, device=device) * -0.1
limits[..., 1] = torch.rand(num_articulations, articulation.num_joints, device=device) * 0.1
articulation.write_joint_limits_to_sim(limits)

# Check if all values are within the bounds
within_bounds = (articulation._data.default_joint_pos >= limits[..., 0]) & (
articulation._data.default_joint_pos <= limits[..., 1]
)
self.assertTrue(torch.all(within_bounds))

def test_external_force_on_single_body(self):
"""Test application of external force on the base of the articulation."""
for num_articulations in (1, 2):
Expand Down
1 change: 1 addition & 0 deletions tools/per_test_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Any tests not listed here will use the default timeout.
"""
PER_TEST_TIMEOUTS = {
"test_articulation.py": 150,
"test_environments.py": 1200, # This test runs through all the environments for 100 steps each
"test_environment_determinism.py": 200, # This test runs through many the environments for 100 steps each
"test_env_rendering_logic.py": 300,
Expand Down
Loading