Skip to content

Commit

Permalink
Merge pull request #1182 from YutoUchimi/battery_warning
Browse files Browse the repository at this point in the history
Fix battery warning
  • Loading branch information
k-okada authored Dec 11, 2019
2 parents 06047b1 + fd47e81 commit f1fd45b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_warning/battery_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Author: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>

from __future__ import division
from __future__ import unicode_literals

import actionlib
from collections import defaultdict
Expand All @@ -29,7 +30,7 @@ def __init__(self):

# param
self.monitor_rate = rospy.get_param("~monitor_rate", 4)
self.warning_temp = rospy.get_param("~warning_temperature", 41.0)
self.warning_temp = rospy.get_param("~warning_temperature", 42.0)
self.min_capacity = rospy.get_param("~min_capacity", 800)
self.warning_voltage = rospy.get_param("~warning_voltage", 14.0)
self.critical_voltage = rospy.get_param("~critical_voltage", 13.7)
Expand All @@ -50,14 +51,18 @@ def __init__(self):
rospy.Duration(self.log_rate), self.log_cb)

def speak(self, sentence):
if self.speech_history[sentence] + rospy.Duration(self.warn_repeat_rate) > rospy.Time.now():
# Pick first 4 characters as a keyword instead of using whole sentence
# because sentence can have variables like 100%, 90%, etc.
key = sentence[:4]
if self.speech_history[key] + rospy.Duration(self.warn_repeat_rate) > rospy.Time.now():
return
self.speech_history[sentence] = rospy.Time.now()
self.speech_history[key] = rospy.Time.now()
req = SoundRequest()
req.command = SoundRequest.PLAY_ONCE
req.sound = SoundRequest.SAY
req.arg = sentence
req.arg2 = "ja"
req.volume = 1.0
self.speak_client.send_goal(SoundRequestGoal(sound_request=req))
self.speak_client.wait_for_result(timeout=rospy.Duration(10))

Expand Down

0 comments on commit f1fd45b

Please sign in to comment.