Skip to content

Commit

Permalink
[jsk_robot_startup/shutdown.py] Parameterize timeout values
Browse files Browse the repository at this point in the history
  • Loading branch information
nakane11 authored Sep 10, 2022
1 parent ad9f3da commit b69f13f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jsk_robot_common/jsk_robot_startup/scripts/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ def __init__(self):
self.reboot_command = rospy.get_param(
'~reboot_command', '/sbin/shutdown -r now')
self.volume = rospy.get_param('~volume', 1.0)
self.timeout_server = rospy.get_param('~timeout_server', 1.0)
self.timeout_result = rospy.get_param('~timeout_result', 10.0)

def speak(self, text, lang='jp'):
if self.client.wait_for_server(timeout=rospy.Duration(1.0)):
timeout_server = rospy.Duration(self.timeout_server)
timeout_result = rospy.Duration(self.timeout_result)
if self.client.wait_for_server(timeout=timeout_server):
msg = SoundRequest()
msg.sound = SoundRequest.SAY
msg.command = SoundRequest.PLAY_ONCE
Expand All @@ -68,7 +72,7 @@ def speak(self, text, lang='jp'):
msg.arg2 = lang
goal = SoundRequestGoal(sound_request=msg)
self.client.send_goal(goal)
self.client.wait_for_result(timeout=rospy.Duration(10.0))
self.client.wait_for_result(timeout=timeout_result)
return self.client.get_result()

def callback(self, msg):
Expand Down

0 comments on commit b69f13f

Please sign in to comment.