Unverified Commit 8e57a3a6 authored by James Tigue's avatar James Tigue Committed by GitHub

Adds math tests for transforms, rotations, and conversions (#103) (#2801)

# Description

this PR adds tests for:

- scale_transform
- unscale_transform
- saturate
- normalize
- copysign
- convert_quat
- quat_conjugate
- quat_from_euler_xyz
- quat_from_matrix
- euler_xyz_from_quat
- matrix_from_euler
- quat_from_angle_axis
- axis_angle_from_quat
- skew_symmetric_matrix
- combine_transform
- subtract_transform
- compute_pose_error

Fixes # (issue)

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)

## Checklist

- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------
Signed-off-by: 's avatarJames Tigue <166445701+jtigue-bdai@users.noreply.github.com>
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 0eb323ed
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.40.16" version = "0.40.17"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.40.17 (2025-07-10)
~~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added unit tests for multiple math functions:
:func:`~isaaclab.utils.math.scale_transform`.
:func:`~isaaclab.utils.math.unscale_transform`.
:func:`~isaaclab.utils.math.saturate`.
:func:`~isaaclab.utils.math.normalize`.
:func:`~isaaclab.utils.math.copysign`.
:func:`~isaaclab.utils.math.convert_quat`.
:func:`~isaaclab.utils.math.quat_conjugate`.
:func:`~isaaclab.utils.math.quat_from_euler_xyz`.
:func:`~isaaclab.utils.math.quat_from_matrix`.
:func:`~isaaclab.utils.math.euler_xyz_from_quat`.
:func:`~isaaclab.utils.math.matrix_from_euler`.
:func:`~isaaclab.utils.math.quat_from_angle_axis`.
:func:`~isaaclab.utils.math.axis_angle_from_quat`.
:func:`~isaaclab.utils.math.skew_symmetric_matrix`.
:func:`~isaaclab.utils.math.combine_transform`.
:func:`~isaaclab.utils.math.subtract_transform`.
:func:`~isaaclab.utils.math.compute_pose_error`.
Changed
^^^^^^^
* Changed the implementation of :func:`~isaaclab.utils.math.copysign` to better reflect the documented functionality.
0.40.16 (2025-07-08) 0.40.16 (2025-07-08)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
......
...@@ -133,8 +133,8 @@ def copysign(mag: float, other: torch.Tensor) -> torch.Tensor: ...@@ -133,8 +133,8 @@ def copysign(mag: float, other: torch.Tensor) -> torch.Tensor:
Returns: Returns:
The output tensor. The output tensor.
""" """
mag_torch = torch.tensor(mag, device=other.device, dtype=torch.float).repeat(other.shape[0]) mag_torch = abs(mag) * torch.ones_like(other)
return torch.abs(mag_torch) * torch.sign(other) return torch.copysign(mag_torch, other)
""" """
...@@ -250,7 +250,7 @@ def quat_conjugate(q: torch.Tensor) -> torch.Tensor: ...@@ -250,7 +250,7 @@ def quat_conjugate(q: torch.Tensor) -> torch.Tensor:
""" """
shape = q.shape shape = q.shape
q = q.reshape(-1, 4) 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 @torch.jit.script
...@@ -401,7 +401,7 @@ def _axis_angle_rotation(axis: Literal["X", "Y", "Z"], angle: torch.Tensor) -> t ...@@ -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: 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: Args:
euler_angles: Euler angles in radians. Shape is (..., 3). euler_angles: Euler angles in radians. Shape is (..., 3).
...@@ -436,7 +436,7 @@ def euler_xyz_from_quat( ...@@ -436,7 +436,7 @@ def euler_xyz_from_quat(
"""Convert rotations given as quaternions to Euler angles in radians. """Convert rotations given as quaternions to Euler angles in radians.
Note: Note:
The euler angles are assumed in XYZ convention. The euler angles are assumed in XYZ extrinsic convention.
Args: Args:
quat: The quaternion orientation in (w, x, y, z). Shape is (N, 4). quat: The quaternion orientation in (w, x, y, z). Shape is (N, 4).
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment