Skip to content

Commit b50ef9e

Browse files
Added check and escape if calibration tag is not detected at any point
in the calibration sequence - this requirement can be later relaxed as more testing is done
1 parent a372638 commit b50ef9e

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

arm_commander/commander_moveit.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,10 @@ def get_transform_as_pose(self, tf_buffer, from_frame, to_frame):
12911291

12921292
def capture_joints(self):
12931293
print("Setting up the listener...")
1294+
if self.is_target_visible() == False:
1295+
rospy.logerr(f'Failed to detect calibration target at current joint capture location...')
1296+
return
1297+
12941298
self.init_transform_listener()
12951299
try:
12961300
object_pose = self.get_transform_as_pose(self.tf_buffer, 'camera_color_optical_frame', 'handeye_target')
@@ -1348,6 +1352,10 @@ def capture_target_sequence(self, script_file:str):
13481352
time.sleep(1)
13491353
self.capture_joints()
13501354

1355+
if len(self.capture_results) < len(joint_values): # this could be some portion of the locations if we knew the tolerance
1356+
print(f"Failed to collect estimates at all {len(joint_values)} positions - only captured {len(self.capture_results)}")
1357+
return []
1358+
13511359
return self.capture_results
13521360

13531361
def calibrate_tank(self, reference_frame:str=None, reference_pose:Pose=None) -> Pose:
@@ -1405,7 +1413,7 @@ def calibrate_tank(self, reference_frame:str=None, reference_pose:Pose=None) ->
14051413
detector_init_success = self.set_charuco_detector_params(longest_board_size=0.1970, measured_marker_size=0.0170)
14061414
if not detector_init_success:
14071415
rospy.logerr('The commander (calibrate_tank): failed to set the charuco detector parameters')
1408-
return center # TODO: return error code
1416+
return Pose()
14091417

14101418
# Move to Tank Ready Pose
14111419
self.move_to_named_pose(tank_ready_named_pose, True)
@@ -1415,48 +1423,51 @@ def calibrate_tank(self, reference_frame:str=None, reference_pose:Pose=None) ->
14151423
# -- Ensure tag is visible
14161424
if self.is_target_visible(timeout=10.0) == False:
14171425
rospy.logerr('The commander (calibrate_tank): tag 1 not visible')
1418-
return center
1426+
return Pose()
14191427
# -- Calibration sequence for tag_1
14201428
tag_1_samples = self.capture_target_sequence(tag_1_script)
14211429
if len(tag_1_samples) == 0:
14221430
rospy.logerr('The commander (calibrate_tank): failed to capture the target sequence for tag 1')
14231431
self.move_to_named_pose(tank_ready_named_pose, True)
14241432
self.move_to_named_pose('named_poses.ready', True)
1425-
return center
1433+
return Pose()
14261434

14271435
# Move to Tag 2
14281436
self.move_to_named_pose(tank_ready_named_pose, True)
14291437
self.move_to_named_pose(tag_2, True)
14301438
# -- Ensure tag is visible
14311439
if self.is_target_visible(timeout=10.0) == False:
14321440
rospy.logerr('The commander (calibrate_tank): tag 2 not visible')
1433-
return center
1441+
return Pose()
14341442
# -- Calibration sequence for tag_2
14351443
tag_2_samples = self.capture_target_sequence(tag_2_script)
14361444
if len(tag_2_samples) == 0:
14371445
rospy.logerr('The commander (calibrate_tank): failed to capture the target sequence for tag 1')
14381446
self.move_to_named_pose(tank_ready_named_pose, True)
14391447
self.move_to_named_pose('named_poses.ready', True)
1440-
return center
1448+
return Pose()
14411449

14421450
# Move to Tag 3
14431451
self.move_to_named_pose(tank_ready_named_pose, True)
14441452
self.move_to_named_pose(tag_3, True)
14451453
# -- Ensure tag is visible
14461454
if self.is_target_visible(timeout=10.0) == False:
14471455
rospy.logerr('The commander (calibrate_tank): tag 3 not visible')
1448-
return center
1456+
return Pose()
14491457
# -- Calibration sequence for tag_3
14501458
tag_3_samples = self.capture_target_sequence(tag_3_script)
14511459
if len(tag_3_samples) == 0:
14521460
rospy.logerr('The commander (calibrate_tank): failed to capture the target sequence for tag 1')
14531461
self.move_to_named_pose(tank_ready_named_pose, True)
14541462
self.move_to_named_pose('named_poses.ready', True)
1455-
return center
1463+
return Pose()
14561464

14571465
# -- Process the captured samples
14581466
why = TankLeastSquares(tank_id, tag_1_samples, tag_2_samples, tag_3_samples)
14591467
center = why.get_tank_center_pose()
1468+
# -- TODO: actual error checking with known tolerance
1469+
# -- -- return Pose() if tolerance not met..e.g. min/max X,Y,Z,R,P,Y
1470+
14601471
# transform center to world_tf
14611472
center_posestamped = PoseStamped()
14621473
center_posestamped.header.frame_id = 'base_link'

0 commit comments

Comments
 (0)