Skip to content

Commit 3ff7f3c

Browse files
author
Peter
committed
add test to address review
1 parent 25cd7c4 commit 3ff7f3c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/pytorch_kinematics/transforms/rotation_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def axis_angle_to_matrix(axis_angle):
538538
Returns:
539539
Rotation matrices as tensor of shape (..., 3, 3).
540540
"""
541-
warn('This is deprecated because it is slow. Use axis_and_angle_to_matrix',
541+
warn('This is deprecated because it is slow. Use axis_and_angle_to_matrix_33 instead.',
542542
DeprecationWarning, stacklevel=2)
543543
return quaternion_to_matrix(axis_angle_to_quaternion(axis_angle))
544544

tests/test_rotation_conversions.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import timeit
22

3+
import numpy as np
34
import torch
45

56
from pytorch_kinematics.transforms.rotation_conversions import axis_and_angle_to_matrix_33, axis_angle_to_matrix, \
6-
pos_rot_to_matrix, matrix_to_pos_rot, random_rotations
7+
pos_rot_to_matrix, matrix_to_pos_rot, random_rotations, quaternion_from_euler
78

89

910
def test_axis_angle_to_matrix_perf():
@@ -22,6 +23,21 @@ def test_axis_angle_to_matrix_perf():
2223
print(f'New method: {dt2:.5f}')
2324

2425

26+
def test_quaternion_from_euler():
27+
q = quaternion_from_euler(0, 0, 0)
28+
np.testing.assert_allclose(q, np.array([1., 0, 0, 0]))
29+
root2_over_2 = np.sqrt(2) / 2
30+
31+
q = quaternion_from_euler(0, 0, np.pi / 2)
32+
np.testing.assert_allclose(q, np.array([root2_over_2, 0, 0, root2_over_2]))
33+
34+
q = quaternion_from_euler(-np.pi / 2, 0, 0)
35+
np.testing.assert_allclose(q, np.array([root2_over_2, -root2_over_2, 0, 0]))
36+
37+
q = quaternion_from_euler(0, np.pi / 2, 0)
38+
np.testing.assert_allclose(q, np.array([root2_over_2, 0, root2_over_2, 0]))
39+
40+
2541
def test_pos_rot_conversion():
2642
N = 1000
2743
R = random_rotations(N)

0 commit comments

Comments
 (0)