Example #1
0
    def old_query(self, spec, choices, timeout=10):
        '''
        Convert old queryies to a HMI query
        '''
        rospy.loginfo('spec: %s', _truncate(spec))
        _print_example(spec, choices)

        self._send_query('', spec, choices)
        try:
            answer = self._wait_for_result_and_get(timeout=timeout)
        except TimeoutException:
            return GetSpeechResponse(result="")
        except:
            return None
        else:
            # so we've got an answer
            self.last_talker_id = answer.talker_id  # Keep track of the last talker_id
            _print_answer(answer)

            # convert it to the old message
            choices = resultFromROS(answer)
            result = GetSpeechResponse(result=answer.raw_result)
            result.choices = choices

            return result
Example #2
0
    def query(self, description, spec, choices, timeout=10):
        '''
        Perform a HMI query, returns a dict of {choicename: value}
        '''
        rospy.loginfo('Question: %s, spec: %s', description, _truncate(spec))
        _print_example(spec, choices)

        self._send_query(description, spec, choices)
        answer = self._wait_for_result_and_get(timeout=timeout)

        self.last_talker_id = answer.talker_id  # Keep track of the last talker_id

        _print_answer(answer)
        return resultFromROS(answer)
Example #3
0
def _print_answer(answer):
    rospy.loginfo("Robot heard \x1b[1;42m'{}'\x1b[0m {}".format(answer.raw_result, resultFromROS(answer)))