Skip to content

Commit 634e32e

Browse files
committed
Add unit test.
1 parent b9922d0 commit 634e32e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/test_pose3d.py

+40
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,46 @@ def test_rtvec(self):
13891389
nt.assert_equal(rvec, [0, 1, 0])
13901390
nt.assert_equal(tvec, [2, 3, 4])
13911391

1392+
def test_interp(self):
1393+
# This data is taken from https://github.com/bdaiinstitute/spatialmath-python/issues/165
1394+
se3_1 = SE3()
1395+
se3_1.t = np.array(
1396+
[0.5705748101710814, 0.29623210833184527, 0.10764106509086407]
1397+
)
1398+
se3_1.R = np.array(
1399+
[
1400+
[0.2852875203191073, 0.9581330588259315, -0.024332536551692617],
1401+
[0.9582072394229962, -0.28568756930438033, -0.014882844564011068],
1402+
[-0.021211248608609852, -0.019069722856395098, -0.9995931315303468],
1403+
]
1404+
)
1405+
assert SE3.isvalid(se3_1.A)
1406+
1407+
se3_2 = SE3()
1408+
se3_2.t = np.array(
1409+
[0.5150284150005691, 0.25796537207802533, 0.1558725490743694]
1410+
)
1411+
se3_2.R = np.array(
1412+
[
1413+
[0.42058255728234184, 0.9064420651629983, -0.038380919906699236],
1414+
[0.9070822373513454, -0.4209501599465646, -0.0016665901233428627],
1415+
[-0.01766712176680449, -0.0341137119645545, -0.9992617912561634],
1416+
]
1417+
)
1418+
assert SE3.isvalid(se3_2.A)
1419+
1420+
path_se3 = se3_1.interp(end=se3_2, s=15, shortest=False)
1421+
1422+
angle = None
1423+
for i in range(len(path_se3) - 1):
1424+
assert SE3.isvalid(path_se3[i].A)
1425+
1426+
if angle is None:
1427+
angle = path_se3[i].angdist(path_se3[i + 1])
1428+
else:
1429+
test_angle = path_se3[i].angdist(path_se3[i + 1])
1430+
assert abs(test_angle - angle) < 1e-6
1431+
13921432

13931433
# ---------------------------------------------------------------------------------------#
13941434
if __name__ == "__main__":

0 commit comments

Comments
 (0)