def __init__(self): rospy.on_shutdown(self.cleanup) self.rate = rospy.get_param("~rate", 5) r = rospy.Rate(self.rate) self.paused = False # Initialize the Voice message we will publish. self.msg_location = pandu_voice_message() self.msg_person = pandu_voice_message() self.msg_object = pandu_voice_message() self.msg_location.first_string = 'none' self.msg_location.second_string = 'none' self.msg_person.first_string = 'none' self.msg_person.second_string = 'none' self.msg_object.first_string = 'none' self.msg_object.second_string = 'none' # Publish the Voice message to various topics self.loc_cmd_pub = rospy.Publisher('voice_location_cmd', pandu_voice_message) self.loc_ack_pub = rospy.Publisher('voice_location_ack', pandu_voice_message) self.per_cmd_pub = rospy.Publisher('voice_person_cmd', pandu_voice_message) self.obj_cmd_pub = rospy.Publisher('voice_object_cmd', pandu_voice_message) # Subscribe to the /recognizer/output topic to receive voice commands. self.voice = rospy.get_param("~voice", "voice_don_diphone") self.soundhandle = SoundClient() rospy.sleep(1) self.soundhandle.stopAll() rospy.sleep(1) self.soundhandle.say("Pandubot is ready to receive commands", self.voice) rospy.Subscriber('/recognizer/output', String, self.speechCb) rospy.Subscriber('/voice_location_ack', pandu_voice_message, self.synthesizer_loc) rospy.Subscriber('/voice_person_ack', pandu_voice_message, self.synthesizer_per) rospy.Subscriber('/voice_object_ack', pandu_voice_message, self.synthesizer_obj) # A mapping from keywords to commands. self.keywords_to_command = {'navigate' : ['go to', 'go', 'reach'], 'fetch' : ['fetch', 'get'], 'vending machine' : ['vending machine'], 'dustbin' : ['dustbin'], 'bench' : ['bench'], 'bump space' : ['bump space'], 'home' : ['home'], 'snickers' : ['snickers'], 'pause' : ['pandu listen','listen'], 'continue' : ['pandu dont listen', 'do not listen','not listen']} rospy.loginfo("Ready to receive voice commands")
def __init__(self): rospy.on_shutdown(self.cleanup) self.rate = rospy.get_param("~rate", 5) r = rospy.Rate(self.rate) self.paused = False # Initialize the Voice message we will publish. self.msg_location = pandu_voice_message() self.msg_person = pandu_voice_message() self.msg_object = pandu_voice_message() # Publish the Voice message to various topics self.loc_cmd_pub = rospy.Publisher('voice_location_cmd', pandu_voice_message) self.loc_ack_pub = rospy.Publisher('voice_location_ack', pandu_voice_message) self.per_cmd_pub = rospy.Publisher('voice_person_cmd', pandu_voice_message) self.obj_cmd_pub = rospy.Publisher('voice_object_cmd', pandu_voice_message) # Subscribe to the /recognizer/output topic to receive voice commands. rospy.Subscriber('/recognizer/output', String, self.speechCb) # A mapping from keywords to commands. self.keywords_to_command = { 'navigate': ['go to', 'go', 'reach'], 'fetch': ['fetch', 'get'], 'vending machine': ['vending machine'], 'dustbin': ['dustbin'], 'bench': ['bench'], 'bump space': ['bump space'], 'home': ['home'], 'snickers': ['snickers'], 'pause': ['pandu listen', 'listen'], 'continue': ['pandu dont listen', 'do not listen', 'not listen'] } rospy.loginfo("Ready to receive voice commands") # We have to keep publishing the cmd_vel message if we want the robot to keep moving. while not rospy.is_shutdown(): self.loc_cmd_pub.publish(self.msg_location) self.per_cmd_pub.publish(self.msg_person) self.obj_cmd_pub.publish(self.msg_object) r.sleep()
def __init__(self): rospy.on_shutdown(self.cleanup) self.rate = rospy.get_param("~rate", 5) r = rospy.Rate(self.rate) self.paused = False # Initialize the Voice message we will publish. self.msg_location = pandu_voice_message() self.msg_person = pandu_voice_message() self.msg_object = pandu_voice_message() # Publish the Voice message to various topics self.loc_cmd_pub = rospy.Publisher('voice_location_cmd', pandu_voice_message) self.loc_ack_pub = rospy.Publisher('voice_location_ack', pandu_voice_message) self.per_cmd_pub = rospy.Publisher('voice_person_cmd', pandu_voice_message) self.obj_cmd_pub = rospy.Publisher('voice_object_cmd', pandu_voice_message) # Subscribe to the /recognizer/output topic to receive voice commands. rospy.Subscriber('/recognizer/output', String, self.speechCb) # A mapping from keywords to commands. self.keywords_to_command = {'navigate' : ['go to', 'go', 'reach'], 'fetch' : ['fetch', 'get'], 'vending machine' : ['vending machine'], 'dustbin' : ['dustbin'], 'bench' : ['bench'], 'bump space' : ['bump space'], 'home' : ['home'], 'snickers' : ['snickers'], 'pause' : ['pandu listen','listen'], 'continue' : ['pandu dont listen', 'do not listen','not listen']} rospy.loginfo("Ready to receive voice commands") # We have to keep publishing the cmd_vel message if we want the robot to keep moving. while not rospy.is_shutdown(): self.loc_cmd_pub.publish(self.msg_location) self.per_cmd_pub.publish(self.msg_person) self.obj_cmd_pub.publish(self.msg_object) r.sleep()