From 3e77641f90f51b18de614af888afd410a10bf57b Mon Sep 17 00:00:00 2001 From: James Tigue <166445701+jtigue-bdai@users.noreply.github.com> Date: Wed, 18 Jun 2025 09:49:04 -0400 Subject: [PATCH 1/4] Add math tests for transforms, rotations, and conversions (#103) --- source/isaaclab/isaaclab/utils/math.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/source/isaaclab/isaaclab/utils/math.py b/source/isaaclab/isaaclab/utils/math.py index c1e879a87a..f85af20258 100644 --- a/source/isaaclab/isaaclab/utils/math.py +++ b/source/isaaclab/isaaclab/utils/math.py @@ -133,8 +133,8 @@ def copysign(mag: float, other: torch.Tensor) -> torch.Tensor: Returns: The output tensor. """ - mag_torch = torch.tensor(mag, device=other.device, dtype=torch.float).repeat(other.shape[0]) - return torch.abs(mag_torch) * torch.sign(other) + mag_torch = abs(mag) * torch.ones_like(other) + return torch.copysign(mag_torch, other) """ @@ -250,7 +250,7 @@ def quat_conjugate(q: torch.Tensor) -> torch.Tensor: """ shape = q.shape q = q.reshape(-1, 4) - return torch.cat((q[:, 0:1], -q[:, 1:]), dim=-1).view(shape) + return torch.cat((q[..., 0:1], -q[..., 1:]), dim=-1).view(shape) @torch.jit.script @@ -401,7 +401,7 @@ def _axis_angle_rotation(axis: Literal["X", "Y", "Z"], angle: torch.Tensor) -> t def matrix_from_euler(euler_angles: torch.Tensor, convention: str) -> torch.Tensor: """ - Convert rotations given as Euler angles in radians to rotation matrices. + Convert rotations given as Euler angles (intrinsic) in radians to rotation matrices. Args: euler_angles: Euler angles in radians. Shape is (..., 3). @@ -436,7 +436,7 @@ def euler_xyz_from_quat( """Convert rotations given as quaternions to Euler angles in radians. Note: - The euler angles are assumed in XYZ convention. + The euler angles are assumed in XYZ extrinsic convention. Args: quat: The quaternion orientation in (w, x, y, z). Shape is (N, 4). @@ -928,14 +928,8 @@ def compute_pose_error( Raises: ValueError: Invalid rotation error type. """ - # Compute quaternion error (i.e., difference quaternion) - # Reference: https://personal.utdallas.edu/~sxb027100/dock/quaternion.html - # q_current_norm = q_current * q_current_conj - source_quat_norm = quat_mul(q01, quat_conjugate(q01))[:, 0] - # q_current_inv = q_current_conj / q_current_norm - source_quat_inv = quat_conjugate(q01) / source_quat_norm.unsqueeze(-1) - # q_error = q_target * q_current_inv - quat_error = quat_mul(q02, source_quat_inv) + # Compute quaternion error (i.e., quat_box_minus) + quat_error = quat_mul(q01, quat_conjugate(q02)) # Compute position error pos_error = t02 - t01 From efcdb0bd4b563fb624aef143da46a2d2acb23eb1 Mon Sep 17 00:00:00 2001 From: James Tigue Date: Mon, 30 Jun 2025 10:19:57 -0400 Subject: [PATCH 2/4] fix export to onnx with LSTM. --- source/isaaclab_rl/isaaclab_rl/rsl_rl/exporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/isaaclab_rl/isaaclab_rl/rsl_rl/exporter.py b/source/isaaclab_rl/isaaclab_rl/rsl_rl/exporter.py index c61baa7be3..29e7549f77 100644 --- a/source/isaaclab_rl/isaaclab_rl/rsl_rl/exporter.py +++ b/source/isaaclab_rl/isaaclab_rl/rsl_rl/exporter.py @@ -140,6 +140,7 @@ def forward(self, x): def export(self, path, filename): self.to("cpu") + self.eval() if self.is_recurrent: obs = torch.zeros(1, self.rnn.input_size) h_in = torch.zeros(self.rnn.num_layers, 1, self.rnn.hidden_size) From 6eeb642545deef2dc2369d966690f74de2b9f9e3 Mon Sep 17 00:00:00 2001 From: James Tigue Date: Mon, 30 Jun 2025 10:22:57 -0400 Subject: [PATCH 3/4] changelog --- source/isaaclab_rl/config/extension.toml | 2 +- source/isaaclab_rl/docs/CHANGELOG.rst | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/isaaclab_rl/config/extension.toml b/source/isaaclab_rl/config/extension.toml index 9e2c873573..be3b2d895b 100644 --- a/source/isaaclab_rl/config/extension.toml +++ b/source/isaaclab_rl/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.1.6" +version = "0.1.7" # Description title = "Isaac Lab RL" diff --git a/source/isaaclab_rl/docs/CHANGELOG.rst b/source/isaaclab_rl/docs/CHANGELOG.rst index c39bed61f5..bd3771a793 100644 --- a/source/isaaclab_rl/docs/CHANGELOG.rst +++ b/source/isaaclab_rl/docs/CHANGELOG.rst @@ -1,6 +1,15 @@ Changelog --------- +0.1.7 (2025-06-30) +~~~~~~~~~~~~~~~~~~ + +Fixed +^^^^^ + +* Call :meth:`eval` during :meth:`forward`` RSL-RL OnnxPolicyExporter + + 0.1.6 (2025-06-26) ~~~~~~~~~~~~~~~~~~ From 6b2f27565336e0fecdee8adcb0447ded608229e6 Mon Sep 17 00:00:00 2001 From: James Tigue Date: Mon, 30 Jun 2025 13:01:52 -0400 Subject: [PATCH 4/4] Revert "Add math tests for transforms, rotations, and conversions (#103)" This reverts commit 3e77641f90f51b18de614af888afd410a10bf57b. --- source/isaaclab/isaaclab/utils/math.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/source/isaaclab/isaaclab/utils/math.py b/source/isaaclab/isaaclab/utils/math.py index f85af20258..c1e879a87a 100644 --- a/source/isaaclab/isaaclab/utils/math.py +++ b/source/isaaclab/isaaclab/utils/math.py @@ -133,8 +133,8 @@ def copysign(mag: float, other: torch.Tensor) -> torch.Tensor: Returns: The output tensor. """ - mag_torch = abs(mag) * torch.ones_like(other) - return torch.copysign(mag_torch, other) + mag_torch = torch.tensor(mag, device=other.device, dtype=torch.float).repeat(other.shape[0]) + return torch.abs(mag_torch) * torch.sign(other) """ @@ -250,7 +250,7 @@ def quat_conjugate(q: torch.Tensor) -> torch.Tensor: """ shape = q.shape q = q.reshape(-1, 4) - return torch.cat((q[..., 0:1], -q[..., 1:]), dim=-1).view(shape) + return torch.cat((q[:, 0:1], -q[:, 1:]), dim=-1).view(shape) @torch.jit.script @@ -401,7 +401,7 @@ def _axis_angle_rotation(axis: Literal["X", "Y", "Z"], angle: torch.Tensor) -> t def matrix_from_euler(euler_angles: torch.Tensor, convention: str) -> torch.Tensor: """ - Convert rotations given as Euler angles (intrinsic) in radians to rotation matrices. + Convert rotations given as Euler angles in radians to rotation matrices. Args: euler_angles: Euler angles in radians. Shape is (..., 3). @@ -436,7 +436,7 @@ def euler_xyz_from_quat( """Convert rotations given as quaternions to Euler angles in radians. Note: - The euler angles are assumed in XYZ extrinsic convention. + The euler angles are assumed in XYZ convention. Args: quat: The quaternion orientation in (w, x, y, z). Shape is (N, 4). @@ -928,8 +928,14 @@ def compute_pose_error( Raises: ValueError: Invalid rotation error type. """ - # Compute quaternion error (i.e., quat_box_minus) - quat_error = quat_mul(q01, quat_conjugate(q02)) + # Compute quaternion error (i.e., difference quaternion) + # Reference: https://personal.utdallas.edu/~sxb027100/dock/quaternion.html + # q_current_norm = q_current * q_current_conj + source_quat_norm = quat_mul(q01, quat_conjugate(q01))[:, 0] + # q_current_inv = q_current_conj / q_current_norm + source_quat_inv = quat_conjugate(q01) / source_quat_norm.unsqueeze(-1) + # q_error = q_target * q_current_inv + quat_error = quat_mul(q02, source_quat_inv) # Compute position error pos_error = t02 - t01