5858TIMEOUT_WAIT_SERVICE = 10
5959TIMEOUT_WAIT_SERVICE_INITIAL = 60
6060TIMEOUT_WAIT_ACTION = 10
61+ TIMEOUT_EXECUTE_TRAJECTORY = 30
6162
6263ROBOT_JOINTS = [
6364 "elbow_joint" ,
@@ -283,7 +284,9 @@ def test_trajectory(self):
283284
284285 # Verify execution
285286 result = self .get_result (
286- "/scaled_joint_trajectory_controller/follow_joint_trajectory" , goal_response
287+ "/scaled_joint_trajectory_controller/follow_joint_trajectory" ,
288+ goal_response ,
289+ TIMEOUT_EXECUTE_TRAJECTORY ,
287290 )
288291 self .assertEqual (result .error_code , FollowJointTrajectory .Result .SUCCESSFUL )
289292 self .node .get_logger ().info ("Received result SUCCESSFUL" )
@@ -349,7 +352,9 @@ def test_trajectory_scaled(self):
349352
350353 if goal_response .accepted :
351354 result = self .get_result (
352- "/scaled_joint_trajectory_controller/follow_joint_trajectory" , goal_response
355+ "/scaled_joint_trajectory_controller/follow_joint_trajectory" ,
356+ goal_response ,
357+ TIMEOUT_EXECUTE_TRAJECTORY ,
353358 )
354359 self .assertIn (
355360 result .error_code ,
@@ -373,7 +378,7 @@ def test_trajectory_scaled(self):
373378 # self.assertEqual(goal_response.accepted, True)
374379 #
375380 # if goal_response.accepted:
376- # result = self.get_result("/scaled_joint_trajectory_controller/follow_joint_trajectory", goal_response)
381+ # result = self.get_result("/scaled_joint_trajectory_controller/follow_joint_trajectory", goal_response, TIMEOUT_EXECUTE_TRAJECTORY )
377382 # self.assertEqual(result.error_code, FollowJointTrajectory.Result.GOAL_TOLERANCE_VIOLATED)
378383 # self.node.get_logger().info("Received result GOAL_TOLERANCE_VIOLATED")
379384
@@ -401,10 +406,12 @@ def call_action(self, action_name, goal):
401406 else :
402407 raise Exception (f"Exception while calling action: { future .exception ()} " )
403408
404- def get_result (self , action_name , goal_response ):
405- self .node .get_logger ().info (f"Waiting for result for action server '{ action_name } '" )
409+ def get_result (self , action_name , goal_response , timeout ):
410+ self .node .get_logger ().info (
411+ f"Waiting for result for action server '{ action_name } ' (timeout: { timeout } seconds)"
412+ )
406413 future_res = self .action_clients [action_name ]._get_result_async (goal_response )
407- rclpy .spin_until_future_complete (self .node , future_res )
414+ rclpy .spin_until_future_complete (self .node , future_res , timeout_sec = timeout )
408415
409416 if future_res .result () is not None :
410417 self .node .get_logger ().info (f"Received result { future_res .result ().result } " )
0 commit comments