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

Separates setters inside Articulation for joint position and velocity #1751

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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.30.6"
version = "0.30.7"

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

0.30.7 (2025-01-30)
~~~~~~~~~~~~~~~~~~~

Added
^^^^^

* Added methods inside the :class:`omni.isaac.lab.assets.Articulation` class to set the joint
position and velocity for the articulation. Previously, the joint position and velocity could
only be set using the :meth:`omni.isaac.lab.assets.Articulation.write_joint_state_to_sim` method,
which didn't allow setting the joint position and velocity separately.


0.30.6 (2025-01-17)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,23 @@ def write_joint_state_to_sim(
joint_ids: The joint indices to set the targets for. Defaults to None (all joints).
env_ids: The environment indices to set the targets for. Defaults to None (all environments).
"""
# set into simulation
self.write_joint_position_to_sim(position, joint_ids=joint_ids, env_ids=env_ids)
self.write_joint_velocity_to_sim(velocity, joint_ids=joint_ids, env_ids=env_ids)

def write_joint_position_to_sim(
self,
position: torch.Tensor,
joint_ids: Sequence[int] | slice | None = None,
env_ids: Sequence[int] | slice | None = None,
):
"""Write joint positions to the simulation.

Args:
position: Joint positions. Shape is (len(env_ids), len(joint_ids)).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
position: Joint positions. Shape is (len(env_ids), len(joint_ids)).
position: Joint positions (rad). Shape is (len(env_ids), len(joint_ids)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image I found some reference in Physx about joint units hope this is useful!

joint_ids: The joint indices to set the targets for. Defaults to None (all joints).
env_ids: The environment indices to set the targets for. Defaults to None (all environments).
"""
# resolve indices
physx_env_ids = env_ids
if env_ids is None:
Expand All @@ -494,15 +511,41 @@ def write_joint_state_to_sim(
env_ids = env_ids[:, None]
# set into internal buffers
self._data.joint_pos[env_ids, joint_ids] = position
self._data.joint_vel[env_ids, joint_ids] = velocity
self._data._previous_joint_vel[env_ids, joint_ids] = velocity
self._data.joint_acc[env_ids, joint_ids] = 0.0
# Need to invalidate the buffer to trigger the update with the new root pose.
self._data._body_state_w.timestamp = -1.0
# self._data._body_link_state_w.timestamp = -1.0
# self._data._body_com_state_w.timestamp = -1.0
# set into simulation
self.root_physx_view.set_dof_positions(self._data.joint_pos, indices=physx_env_ids)

def write_joint_velocity_to_sim(
self,
velocity: torch.Tensor,
joint_ids: Sequence[int] | slice | None = None,
env_ids: Sequence[int] | slice | None = None,
):
"""Write joint velocities to the simulation.

Args:
velocity: Joint velocities. Shape is (len(env_ids), len(joint_ids)).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
velocity: Joint velocities. Shape is (len(env_ids), len(joint_ids)).
velocity: Joint velocities (rad/s). Shape is (len(env_ids), len(joint_ids)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Velocities are rad/s for revolute and m/s for prismatic?

joint_ids: The joint indices to set the targets for. Defaults to None (all joints).
env_ids: The environment indices to set the targets for. Defaults to None (all environments).
"""
# resolve indices
physx_env_ids = env_ids
if env_ids is None:
env_ids = slice(None)
physx_env_ids = self._ALL_INDICES
if joint_ids is None:
joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None]
# set into internal buffers
self._data.joint_vel[env_ids, joint_ids] = velocity
self._data._previous_joint_vel[env_ids, joint_ids] = velocity
self._data.joint_acc[env_ids, joint_ids] = 0.0
# set into simulation
self.root_physx_view.set_dof_velocities(self._data.joint_vel, indices=physx_env_ids)

def write_joint_stiffness_to_sim(
Expand Down