Skip to content
Merged
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
35 changes: 35 additions & 0 deletions embodichain/lab/sim/objects/articulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from dexsim.engine import Articulation as _Articulation
from dexsim.types import (
ArticulationFlag,
ArticulationGPUAPIWriteType,
ArticulationGPUAPIReadType,
)
Expand Down Expand Up @@ -1590,6 +1591,40 @@ def set_physical_visible(
for link_name in link_names:
self._entities[env_idx].set_physical_visible(visible, link_name)

def set_fix_base(
self,
fix: bool = True,
env_ids: Sequence[int] | None = None,
) -> None:
"""Set whether the base of the articulation is fixed.

Args:
fix (bool, optional): Whether to fix the base. Defaults to True.
env_ids (Sequence[int] | None, optional): Environment indices. If None, then all indices are used.
"""
local_env_ids = self._all_indices if env_ids is None else env_ids
for i, env_idx in enumerate(local_env_ids):
self._entities[env_idx].set_articulation_flag(
ArticulationFlag.FIX_BASE, fix
)

def set_self_collision(
self,
enable: bool = False,
env_ids: Sequence[int] | None = None,
) -> None:
"""Set whether self-collision is enabled for the articulation.

Args:
enable (bool, optional): Whether to enable self-collision. Defaults to True.
env_ids (Sequence[int] | None, optional): Environment indices. If None, then all indices are used.
"""
local_env_ids = self._all_indices if env_ids is None else env_ids
for i, env_idx in enumerate(local_env_ids):
self._entities[env_idx].set_articulation_flag(
ArticulationFlag.DISABLE_SELF_COLLISION, not enable
)

def destroy(self) -> None:
env = self._world.get_env()
arenas = env.get_all_arenas()
Expand Down
9 changes: 9 additions & 0 deletions tests/sim/objects/test_articulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ def test_set_physical_visible(self):
all_link_names = self.art.link_names
self.art.set_physical_visible(visible=True, link_names=all_link_names[:3])

def test_setter_methods(self):
"""Test setter methods for articulation properties."""
# Test setting fix_base
self.art.set_fix_base(True)
self.art.set_fix_base(False)

self.art.set_self_collision(False)
self.art.set_self_collision(True)

def teardown_method(self):
"""Clean up resources after each test method."""
self.sim.destroy()
Expand Down