diff --git a/hlpr_speech_recognition/config/speech.yaml b/hlpr_speech_recognition/config/speech.yaml index 1005cc5..37fd35d 100644 --- a/hlpr_speech_recognition/config/speech.yaml +++ b/hlpr_speech_recognition/config/speech.yaml @@ -7,4 +7,5 @@ speech: command_type: 'StampedString' # default StampedString (string vs. stampedstring) rec_threshold: 300 # default 300 service_topic: 'get_last_speech_cmd' # default 'get_last_speech_cmd' + leave_command: false # default false diff --git a/hlpr_speech_recognition/src/hlpr_speech_recognition/speech_listener.py b/hlpr_speech_recognition/src/hlpr_speech_recognition/speech_listener.py index 9a8789f..3da01f4 100755 --- a/hlpr_speech_recognition/src/hlpr_speech_recognition/speech_listener.py +++ b/hlpr_speech_recognition/src/hlpr_speech_recognition/speech_listener.py @@ -57,6 +57,7 @@ class SpeechListener: SERVICE_TOPIC_PARAM = "/speech/service_topic" KEYWORDS_PARAM = "/speech/keywords" COMMAND_TYPE = "/speech/command_type" + LEAVE_COMMAND = "/speech/leave_command" def __init__(self, commandBuffSize=10, init_node=True): @@ -75,6 +76,7 @@ def __init__(self, commandBuffSize=10, init_node=True): self.yaml_files = rospy.get_param("~yaml_list", default_yaml_files) self.service_topic = rospy.get_param(SpeechListener.SERVICE_TOPIC_PARAM, default_service_topic) self.msg_type = eval(rospy.get_param(SpeechListener.COMMAND_TYPE, 'StampedString')) # True if message is only str, false includes header + self.leave_command_flag = rospy.get_param(SpeechListener.LEAVE_COMMAND, False) #do we care if we the last command is old rospy.Subscriber(self.recog_topic, self.msg_type, self.callback) @@ -93,6 +95,7 @@ def __init__(self, commandBuffSize=10, init_node=True): # Flags for starting/stopping the node self.spinning = False self.last_command_fresh = False + self.last_command = None self.last_ts = None self.last_string = None @@ -123,9 +126,13 @@ def _map_keyword_to_command(self, data): # This is now made a service call def get_last_command(self, req=None): - # returns a service request error - if not self.last_command_fresh: - return None + + # Check if we care how "recent" the command was + if not self.leave_command_flag: + + # returns a service request error + if not self.last_command_fresh: + return None # The command hasn't been ask for before self.last_command_fresh = False