Skip to content

Commit

Permalink
Issue #68 swapped rotation and translation vectors in return from get…
Browse files Browse the repository at this point in the history
… smooth frame
  • Loading branch information
thompson318 committed Oct 5, 2023
1 parent ada4e58 commit c298e3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 6 additions & 4 deletions sksurgerycore/baseclasses/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def get_smooth_frame(self, port_handles):
tracking : list of 4x4 tracking matrices, rotation and position,
or if use_quaternions is true, a list of tracking quaternions,
column 0-2 is x,y,z column 3-6 is the rotation as a quaternion.
column 0-3 is the rotation as a quaternion (qw, qx, qy, qz),
column 4-6 is the translation (x,y,z).
tracking_quality : list the tracking quality, one per tool.
"""
Expand All @@ -75,8 +76,8 @@ def get_smooth_frame(self, port_handles):

if self.use_quaternions:
output_matrix = np.full((7,1), np.nan)
output_matrix[0:3,0] = mean_tvec
output_matrix[3:7,0] = mean_quat
output_matrix[0:4,0] = mean_quat
output_matrix[4:7,0] = mean_tvec
smth_tracking.append(output_matrix)

else:
Expand Down Expand Up @@ -155,7 +156,8 @@ def get_frame(self):
tracking : list of 4x4 tracking matrices, rotation and position,
or if use_quaternions is true, a list of tracking quaternions,
column 0-2 is x,y,z column 3-6 is the rotation as a quaternion.
column 0-3 is the rotation as a quaternion (qw, qx, qy, qz),
column 4-6 is the translation (x,y,z).
tracking_quality : list the tracking quality, one per tool.
"""
Expand Down
20 changes: 10 additions & 10 deletions tests/baseclasses/test_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def test_tracker_quaternions():
assert frame_numbers[test_index] == 0
transform = np.full((7,1), np.nan)
rotation = _rvec_to_quaternion([1.0, 0.0, 0.0])
transform[3:7,0] = rotation
transform[0:3,0] = [0.0, 100.0, 200.0]
transform[0:4,0] = rotation
transform[4:7,0] = [0.0, 100.0, 200.0]
assert np.allclose(tracking[test_index], transform)
assert tracking_quality[test_index] == 0.5

Expand Down Expand Up @@ -244,8 +244,8 @@ def test_tracker_quaternions():
assert frame_numbers[test_index] == 1

rotation = _rvec_to_quaternion([0.6, 0.0, 0.0])
transform[3:7,0] = rotation
transform[0:3,0] = [5.0, 75.0, 200.0]
transform[0:4,0] = rotation
transform[4:7,0] = [5.0, 75.0, 200.0]
assert np.allclose(tracking[test_index], transform)
assert tracking_quality[test_index] == 0.65

Expand All @@ -254,8 +254,8 @@ def test_tracker_quaternions():
assert frame_numbers[test_index] == 0

rotation = _rvec_to_quaternion([0.0, 0.0, 0.0])
transform[3:7,0] = rotation
transform[0:3,0] = [50.0, -100.0, 70.0]
transform[0:4,0] = rotation
transform[4:7,0] = [50.0, -100.0, 70.0]
assert np.allclose(tracking[test_index], transform)
assert tracking_quality[test_index] == 1.0

Expand Down Expand Up @@ -284,8 +284,8 @@ def test_tracker_quaternions():
assert time_stamps[test_index] == 1.4
assert frame_numbers[test_index] == 2
rotation = _rvec_to_quaternion([0.0, 0.45, 0.0])
transform[3:7,0] = rotation
transform[0:3,0] = [50.0, -100.0, 70.0]
transform[4:7,0] = [50.0, -100.0, 70.0]
transform[0:4,0] = rotation
assert np.allclose(tracking[test_index], transform)
assert tracking_quality[test_index] == 1.0

Expand All @@ -300,7 +300,7 @@ def test_tracker_quaternions():
assert math.isclose(time_stamps[test_index],1.4)
assert frame_numbers[test_index] == 2
rotation = _rvec_to_quaternion([0.6, 0.00, 0.0])
transform[3:7,0] = rotation
transform[0:3,0] = [3.333333, 83.33333, 166.666667]
transform[0:4,0] = rotation
transform[4:7,0] = [3.333333, 83.33333, 166.666667]
assert np.allclose(tracking[test_index], transform)
assert tracking_quality[test_index] == 0.6

0 comments on commit c298e3d

Please sign in to comment.