@@ -1329,10 +1329,13 @@ def capture_joints(self):
13291329
13301330 def capture_target_sequence (self , script_file :str ):
13311331
1332+ import rospkg
13321333 import yaml
1334+ rospack = rospkg .RosPack ()
1335+ scene_path = rospack .get_path ('cgras_scene' )
13331336 # Read
13341337 # TODO: set the path properly
1335- with open (f'/home/qcr/cgras2025_ws/src/scripts/calibration /{ script_file } ' , newline = '' ) as the_file :
1338+ with open (f'{ scene_path } /calibration_joint_sequences /{ script_file } ' , newline = '' ) as the_file :
13361339 joint_state_dict = yaml .safe_load (the_file )
13371340 joint_values = joint_state_dict ['joint_values' ]
13381341 print (f"Number of locations read: { len (joint_values )} " )
@@ -1413,7 +1416,7 @@ def calibrate_tank(self, reference_frame:str=None, reference_pose:Pose=None) ->
14131416 detector_init_success = self .set_charuco_detector_params (longest_board_size = 0.1970 , measured_marker_size = 0.0170 )
14141417 if not detector_init_success :
14151418 rospy .logerr ('The commander (calibrate_tank): failed to set the charuco detector parameters' )
1416- return Pose ( )
1419+ raise Exception ( '-- Charuco detector service failed...' )
14171420
14181421 # Move to Tank Ready Pose
14191422 self .move_to_named_pose (tank_ready_named_pose , True )
@@ -1423,50 +1426,61 @@ def calibrate_tank(self, reference_frame:str=None, reference_pose:Pose=None) ->
14231426 # -- Ensure tag is visible
14241427 if self .is_target_visible (timeout = 10.0 ) == False :
14251428 rospy .logerr ('The commander (calibrate_tank): tag 1 not visible' )
1426- return Pose ()
1429+ self .move_to_named_pose (tank_ready_named_pose , True )
1430+ self .move_to_named_pose ('named_poses.ready' , True )
1431+ raise Exception ('tag 1 not visible' )
14271432 # -- Calibration sequence for tag_1
14281433 tag_1_samples = self .capture_target_sequence (tag_1_script )
14291434 if len (tag_1_samples ) == 0 :
14301435 rospy .logerr ('The commander (calibrate_tank): failed to capture the target sequence for tag 1' )
14311436 self .move_to_named_pose (tank_ready_named_pose , True )
14321437 self .move_to_named_pose ('named_poses.ready' , True )
1433- return Pose ( )
1438+ raise Exception ( 'tag 1 - failed capture' )
14341439
14351440 # Move to Tag 2
14361441 self .move_to_named_pose (tank_ready_named_pose , True )
14371442 self .move_to_named_pose (tag_2 , True )
14381443 # -- Ensure tag is visible
14391444 if self .is_target_visible (timeout = 10.0 ) == False :
14401445 rospy .logerr ('The commander (calibrate_tank): tag 2 not visible' )
1441- return Pose ()
1446+ self .move_to_named_pose (tank_ready_named_pose , True )
1447+ self .move_to_named_pose ('named_poses.ready' , True )
1448+ raise Exception ('tag 2 not visible' )
14421449 # -- Calibration sequence for tag_2
14431450 tag_2_samples = self .capture_target_sequence (tag_2_script )
14441451 if len (tag_2_samples ) == 0 :
14451452 rospy .logerr ('The commander (calibrate_tank): failed to capture the target sequence for tag 1' )
14461453 self .move_to_named_pose (tank_ready_named_pose , True )
14471454 self .move_to_named_pose ('named_poses.ready' , True )
1448- return Pose ( )
1455+ raise Exception ( 'tag 2 - failed capture' )
14491456
14501457 # Move to Tag 3
14511458 self .move_to_named_pose (tank_ready_named_pose , True )
14521459 self .move_to_named_pose (tag_3 , True )
14531460 # -- Ensure tag is visible
14541461 if self .is_target_visible (timeout = 10.0 ) == False :
14551462 rospy .logerr ('The commander (calibrate_tank): tag 3 not visible' )
1456- return Pose ()
1463+ self .move_to_named_pose (tank_ready_named_pose , True )
1464+ self .move_to_named_pose ('named_poses.ready' , True )
1465+ raise Exception ('tag 3 not visible' )
14571466 # -- Calibration sequence for tag_3
14581467 tag_3_samples = self .capture_target_sequence (tag_3_script )
14591468 if len (tag_3_samples ) == 0 :
14601469 rospy .logerr ('The commander (calibrate_tank): failed to capture the target sequence for tag 1' )
14611470 self .move_to_named_pose (tank_ready_named_pose , True )
14621471 self .move_to_named_pose ('named_poses.ready' , True )
1463- return Pose ( )
1472+ raise Exception ( 'tag 3 - failed capture' )
14641473
14651474 # -- Process the captured samples
14661475 why = TankLeastSquares (tank_id , tag_1_samples , tag_2_samples , tag_3_samples )
14671476 center = why .get_tank_center_pose ()
14681477 # -- TODO: actual error checking with known tolerance
1469- # -- -- return Pose() if tolerance not met..e.g. min/max X,Y,Z,R,P,Y
1478+ # -- -- raise Exception if tolerance not met..e.g. min/max X,Y,Z,R,P,Y
1479+ # e.g.
1480+ if center .position == [0 ,0 ,0 ]:
1481+ self .move_to_named_pose (tank_ready_named_pose , True )
1482+ self .move_to_named_pose ('named_poses.ready' , True )
1483+ raise Exception (f'Tank Center in unacceptable location - { center .position } ' )
14701484
14711485 # transform center to world_tf
14721486 center_posestamped = PoseStamped ()
0 commit comments