From 049a751fdf3e72df490fdea64746714262745f50 Mon Sep 17 00:00:00 2001 From: Kanazawanaoaki Date: Tue, 17 Dec 2024 14:18:13 +0900 Subject: [PATCH] [jsk_pr2_startup] Update to a non-function implementation of play_sound --- .../jsk_pr2_warning/battery_warning.py | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning/battery_warning.py b/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning/battery_warning.py index dc4f9a2058..11e1a390ee 100755 --- a/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning/battery_warning.py +++ b/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning/battery_warning.py @@ -70,20 +70,6 @@ def speak(self, sentence): self.speak_client.send_goal(SoundRequestGoal(sound_request=req)) self.speak_client.wait_for_result(timeout=rospy.Duration(10)) - def play_sound(self, sound): - key = sound - if self.sound_history[key] + rospy.Duration(self.warn_repeat_rate) > rospy.Time.now(): - return - self.sound_history[key] = rospy.Time.now() - sound_req = SoundRequest() - sound_req.sound = sound - sound_req.command = SoundRequest.PLAY_ONCE # 1: PLAY_ONCE - sound_req.volume = 1.0 # Volume(0.0〜1.0) - sound_req.arg = '' - sound_req.arg2 = '' - self.sound_client.send_goal(SoundRequestGoal(sound_request=sound_req)) - self.sound_client.wait_for_result(timeout=rospy.Duration(10)) - def log_cb(self, event): try: if osp.exists(self.log_path): @@ -113,7 +99,18 @@ def stat_cb(self, event): if 60 > max_temp > self.warning_temp: self.speak("バッテリ温度%.1f度。暑いです。部屋の温度を下げてください。" % max_temp) if max_temp > self.cable_warning_temp: - self.play_sound(2) # kan kan + # play sound 2 (kan kan) + key = 2 + if not self.sound_history[key] + rospy.Duration(self.warn_repeat_rate) > rospy.Time.now(): + self.sound_history[key] = rospy.Time.now() + sound_req = SoundRequest() + sound_req.sound = 2 # kan kan + sound_req.command = SoundRequest.PLAY_ONCE # 1: PLAY_ONCE + sound_req.volume = 1.0 # Volume(0.0〜1.0) + sound_req.arg = '' + sound_req.arg2 = '' + self.sound_client.send_goal(SoundRequestGoal(sound_request=sound_req)) + self.sound_client.wait_for_result(timeout=rospy.Duration(10)) self.speak("危険な温度です。電源ケーブルのコネクタを確認して下さい。") except KeyError: pass