Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion source/isaaclab/isaaclab/actuators/actuator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def __init__(
)

self.velocity_limit = self._parse_joint_parameter(self.cfg.velocity_limit, self.velocity_limit_sim)
self.effort_limit = self._parse_joint_parameter(self.cfg.effort_limit, self.effort_limit_sim)
# For effort_limit, use the tensor passed to constructor if cfg.effort_limit is None
effort_default = self.effort_limit_sim if self.cfg.effort_limit is not None else effort_limit
self.effort_limit = self._parse_joint_parameter(self.cfg.effort_limit, effort_default)
Comment thread
JuanaDd marked this conversation as resolved.
Outdated

# create commands buffers for allocation
self.computed_effort = torch.zeros(self._num_envs, self.num_joints, device=self._device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ def _process_actuators_cfg(self):
friction=self._data.default_joint_friction_coeff[:, joint_ids],
dynamic_friction=self._data.default_joint_dynamic_friction_coeff[:, joint_ids],
viscous_friction=self._data.default_joint_viscous_friction_coeff[:, joint_ids],
effort_limit=self._data.joint_effort_limits[:, joint_ids],
effort_limit=self._data.joint_effort_limits[:, joint_ids].clone(),
Comment thread
JuanaDd marked this conversation as resolved.
velocity_limit=self._data.joint_vel_limits[:, joint_ids],
)
# log information on actuator groups
Expand Down Expand Up @@ -1811,6 +1811,7 @@ def _apply_actuator_model(self):
"""
# process actions per group
for actuator in self.actuators.values():

Comment thread
kellyguo11 marked this conversation as resolved.
Outdated
# prepare input for actuator model based on cached data
# TODO : A tensor dict would be nice to do the indexing of all tensors together
control_action = ArticulationActions(
Expand Down
31 changes: 25 additions & 6 deletions source/isaaclab/test/assets/test_articulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,10 +1372,16 @@ def test_setting_velocity_limit_explicit(sim, num_articulations, device, vel_lim
@pytest.mark.parametrize("num_articulations", [1, 2])
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
@pytest.mark.parametrize("effort_limit_sim", [1e5, None])
@pytest.mark.parametrize("effort_limit", [1e2, None])
@pytest.mark.parametrize("effort_limit", [1e2, 80.0, None])
@pytest.mark.isaacsim_ci
def test_setting_effort_limit_implicit(sim, num_articulations, device, effort_limit_sim, effort_limit):
"""Test setting of the effort limit for implicit actuators."""
"""Test setting of effort limit for implicit actuators.

This test verifies the effort limit resolution logic for actuator models implemented in :class:`ActuatorBase`:
- Case 1: If USD value == actuator config value: values match correctly
- Case 2: If USD value != actuator config value: actuator config value is used
- Case 3: If actuator config value is None: USD value is used as default
"""
articulation_cfg = generate_articulation_cfg(
articulation_type="single_joint_implicit",
effort_limit_sim=effort_limit_sim,
Expand Down Expand Up @@ -1419,10 +1425,18 @@ def test_setting_effort_limit_implicit(sim, num_articulations, device, effort_li
@pytest.mark.parametrize("num_articulations", [1, 2])
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
@pytest.mark.parametrize("effort_limit_sim", [1e5, None])
@pytest.mark.parametrize("effort_limit", [1e2, None])
@pytest.mark.parametrize("effort_limit", [80.0, 1e2, None])
@pytest.mark.isaacsim_ci
def test_setting_effort_limit_explicit(sim, num_articulations, device, effort_limit_sim, effort_limit):
"""Test setting of effort limit for explicit actuators."""
"""Test setting of effort limit for explicit actuators.

This test verifies the effort limit resolution logic for actuator models implemented in :class:`ActuatorBase`:
- Case 1: If USD value == actuator config value: values match correctly
- Case 2: If USD value != actuator config value: actuator config value is used
- Case 3: If actuator config value is None: USD value is used as default

"""

articulation_cfg = generate_articulation_cfg(
articulation_type="single_joint_explicit",
effort_limit_sim=effort_limit_sim,
Expand All @@ -1436,6 +1450,9 @@ def test_setting_effort_limit_explicit(sim, num_articulations, device, effort_li
# Play sim
sim.reset()

# usd default is 80
usd_default = 80.0
Comment thread
JuanaDd marked this conversation as resolved.
Outdated

# collect limit init values
physx_effort_limit = articulation.root_physx_view.get_dof_max_forces().to(device)
actuator_effort_limit = articulation.actuators["joint"].effort_limit
Expand All @@ -1452,8 +1469,9 @@ def test_setting_effort_limit_explicit(sim, num_articulations, device, effort_li
# check physx effort limit does not match the one explicit actuator has
assert not (torch.allclose(actuator_effort_limit, physx_effort_limit))
else:
# check actuator effort_limit is the same as the PhysX default
torch.testing.assert_close(actuator_effort_limit, physx_effort_limit)
# When effort_limit is None, actuator should use USD default values
expected_actuator_effort_limit = torch.full_like(physx_effort_limit, usd_default)
Comment thread
JuanaDd marked this conversation as resolved.
Outdated
torch.testing.assert_close(actuator_effort_limit, expected_actuator_effort_limit)

# when using explicit actuators, the limits are set to high unless user overrides
if effort_limit_sim is not None:
Expand All @@ -1462,6 +1480,7 @@ def test_setting_effort_limit_explicit(sim, num_articulations, device, effort_li
limit = ActuatorBase._DEFAULT_MAX_EFFORT_SIM # type: ignore
# check physx internal value matches the expected sim value
expected_effort_limit = torch.full_like(physx_effort_limit, limit)
torch.testing.assert_close(actuator_effort_limit_sim, expected_effort_limit)
torch.testing.assert_close(physx_effort_limit, expected_effort_limit)


Expand Down
Loading