Skip to content

Commit c571011

Browse files
committed
Fixed ctgt calculating errors incorrectly
1 parent c033c36 commit c571011

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

atom_core/src/atom_core/utilities.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pynput import keyboard
2626
import yaml
2727

28-
from tf.transformations import quaternion_matrix, euler_from_matrix
28+
from tf.transformations import quaternion_matrix, euler_from_matrix, euler_from_quaternion
2929

3030
from atom_core.naming import generateKey
3131
from atom_core.system import execute, removeColorsFromText
@@ -53,6 +53,7 @@ def compareAtomTransforms(transform_1, transform_2):
5353
transform_2: transformation 2
5454
"""
5555

56+
5657
# Create a 4x4 transformation for transform_1
5758
t1 = quaternion_matrix(transform_1['quat'])
5859
t1[0:3, 3] = transform_1['trans']
@@ -61,21 +62,33 @@ def compareAtomTransforms(transform_1, transform_2):
6162
t2 = quaternion_matrix(transform_2['quat'])
6263
t2[0:3, 3] = transform_2['trans']
6364

64-
# Method: We will use the following method. If T1 and T2 are the same, then multiplying one by the inverse of the other will produce and identity matrix, with zero translation and rotation. So we will do the multiplication and then evaluation the amount of rotation and translation in the resulting matrix.
65+
v = t2[0:3, 3] - t1[0:3, 3]
66+
67+
# Method: We will use the following method. If T1 and T2 are the same, then multiplying one by the inverse of the other will produce and identity matrix, with zero translation and rotation. So we will do the multiplication and then evaluation of the amount of rotation and translation in the resulting matrix.
6568
# print('Comparing \nt1= ' + str(t1) + ' \n\nt2=' + str(t2))
6669

6770
t_delta = np.dot(np.linalg.inv(t1), t2)
6871
# print('t_delta = ' + str(t_delta))
6972

7073
rotation_delta = t_delta[0:3, 0:3]
71-
roll, pitch, yaw = euler_from_matrix(rotation_delta)
72-
74+
# roll, pitch, yaw = euler_from_matrix(rotation_delta)
7375
translation_delta = t_delta[0:3, 3]
74-
# print('translation_delta = ' + str(translation_delta))
76+
77+
euler_angles_init = euler_from_quaternion(transform_1['quat'])
78+
euler_angles_final = euler_from_quaternion(transform_2['quat'])
79+
80+
81+
deuler = np.subtract(euler_angles_final,euler_angles_init)
82+
rotation_error = np.linalg.norm(deuler)
7583

7684
# global metrics
77-
translation_error = float(abs(np.average(translation_delta)))
78-
rotation_error = float(np.average([abs(roll), abs(pitch), abs(yaw)]))
85+
# translation_error = float(abs(np.average(translation_delta)))
86+
translation_error = np.linalg.norm(translation_delta)
87+
# rotation_error = np.linalg.norm([roll, pitch, yaw])
88+
89+
90+
# print('translation error = ' + str(translation_error))
91+
# print('rotation error = ' + str(rotation_error))
7992

8093
return translation_error, rotation_error
8194

@@ -187,7 +200,7 @@ def printComparisonToGroundTruth(
187200
if dataset['calibration_config']['additional_tfs'] is not None:
188201
for additional_tf_key, additional_tf in dataset['calibration_config']['additional_tfs'].items():
189202

190-
transform_key = generateKey(additional_tf["parent_link"], sensor["child_link"])
203+
transform_key = generateKey(additional_tf["parent_link"], additional_tf["child_link"])
191204
row = [transform_key, Fore.LIGHTCYAN_EX + additional_tf_key + Style.RESET_ALL]
192205

193206

atom_examples/softbot/softbot_calibration/urdf/optimized.urdf.xacro

+3-3
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
<child link="lidar3d_plate_link"/>
374374
</joint>
375375
<joint name="lidar3d_base_mount_joint" type="fixed">
376-
<origin xyz="-0.0015142375046177249 -0.0022052142273190152 -0.000283564068925264" rpy="-0.007757658250765604 0.0009838709879697281 -0.014847674947914611"/>
376+
<origin xyz="0.03716082344930228 -0.27220696054487664 0.061596273221005735" rpy="-0.05298232658801819 -0.03810670333805793 -0.10759100238230218"/>
377377
<parent link="lidar3d_plate_link"/>
378378
<child link="lidar3d_base_link"/>
379379
</joint>
@@ -493,7 +493,7 @@
493493
<selfCollide>false</selfCollide>
494494
</gazebo>
495495
<joint name="front_left_camera_rgb_joint" type="fixed">
496-
<origin xyz="-4.399872653456163e-16 -0.04499999999999956 3.1045954087761856e-16" rpy="-4.440829884921592e-16 4.4301780635402403e-16 4.438903032319087e-16"/>
496+
<origin xyz="-4.4406205425347153e-16 -0.045000000000000435 -3.3859777840638286e-16" rpy="-2.6170137566262974e-16 -1.890031503105939e-16 -4.440892059486435e-16"/>
497497
<parent link="front_left_camera_link"/>
498498
<child link="front_left_camera_rgb_frame"/>
499499
</joint>
@@ -586,7 +586,7 @@
586586
<selfCollide>false</selfCollide>
587587
</gazebo>
588588
<joint name="front_right_camera_rgb_joint" type="fixed">
589-
<origin xyz="0.002030911322794242 -0.03938584552044518 -1.2175099096372358e-05" rpy="-0.005222638857532736 0.001007139992505166 -0.0037596367537089353"/>
589+
<origin xyz="-0.6754329952328235 0.01920420891565159 -0.37662191151245966" rpy="0.1461866602192413 -0.12509500646354754 -0.1929261388257878"/>
590590
<parent link="front_right_camera_link"/>
591591
<child link="front_right_camera_rgb_frame"/>
592592
</joint>

atom_examples/softbot/softbot_calibration/urdf/optimized_w_pattern.urdf.xacro

+4-4
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
<child link="lidar3d_plate_link"/>
374374
</joint>
375375
<joint name="lidar3d_base_mount_joint" type="fixed">
376-
<origin xyz="-0.0015142375046177249 -0.0022052142273190152 -0.000283564068925264" rpy="-0.007757658250765604 0.0009838709879697281 -0.014847674947914611"/>
376+
<origin xyz="0.03716082344930228 -0.27220696054487664 0.061596273221005735" rpy="-0.05298232658801819 -0.03810670333805793 -0.10759100238230218"/>
377377
<parent link="lidar3d_plate_link"/>
378378
<child link="lidar3d_base_link"/>
379379
</joint>
@@ -493,7 +493,7 @@
493493
<selfCollide>false</selfCollide>
494494
</gazebo>
495495
<joint name="front_left_camera_rgb_joint" type="fixed">
496-
<origin xyz="-4.399872653456163e-16 -0.04499999999999956 3.1045954087761856e-16" rpy="-4.440829884921592e-16 4.4301780635402403e-16 4.438903032319087e-16"/>
496+
<origin xyz="-4.4406205425347153e-16 -0.045000000000000435 -3.3859777840638286e-16" rpy="-2.6170137566262974e-16 -1.890031503105939e-16 -4.440892059486435e-16"/>
497497
<parent link="front_left_camera_link"/>
498498
<child link="front_left_camera_rgb_frame"/>
499499
</joint>
@@ -586,7 +586,7 @@
586586
<selfCollide>false</selfCollide>
587587
</gazebo>
588588
<joint name="front_right_camera_rgb_joint" type="fixed">
589-
<origin xyz="0.002030911322794242 -0.03938584552044518 -1.2175099096372358e-05" rpy="-0.005222638857532736 0.001007139992505166 -0.0037596367537089353"/>
589+
<origin xyz="-0.6754329952328235 0.01920420891565159 -0.37662191151245966" rpy="0.1461866602192413 -0.12509500646354754 -0.1929261388257878"/>
590590
<parent link="front_right_camera_link"/>
591591
<child link="front_right_camera_rgb_frame"/>
592592
</joint>
@@ -655,7 +655,7 @@
655655
</visual>
656656
</link>
657657
<joint name="world-pattern_link" type="fixed">
658-
<origin xyz="1.273180549764564 0.5275071795462576 0.9180241714021727" rpy="-1.57238029953394 -0.7458089302748174 -1.6092354412755343"/>
658+
<origin xyz="1.1763285302817843 0.6949119593244414 0.7637724865844582" rpy="-1.4378439431950503 -0.421493318623612 -1.8393927091040134"/>
659659
<parent link="world"/>
660660
<child link="pattern_link"/>
661661
</joint>

0 commit comments

Comments
 (0)