def handle_create_new_person(req):
    if req.name != "":
	rospy.loginfo("Creating %s with id %s" % (str(req.name) ,str(req.id)))
	human = Human(req.name, req.id)
	population[req.id] = human
	with open(pop_file, 'w') as file:
	    pickle.dump(population, file)
	interface.add_instance('person', human._person.name, human) 
	return True
    else:
	return False


if __name__ == '__main__':
    rospy.init_node("name_provider_node")
    interface.init()

    pop_file = '/home/yochan/names.pickle'
    if os.path.isfile(pop_file):
	with open(pop_file, 'r') as file:
	    population = pickle.load(file)

    for key in population:
	h = population[key]
	interface.add_instance('person', h._person.name, h) 

    get_name_service = rospy.Service("get_real_name", GetRealName, handle_get_real_name)
    get_name_service = rospy.Service("create_new_person", CreateNewPerson, handle_create_new_person)
    rospy.spin()
Esempio n. 2
0
	(S('change my name') % 'set_name') |
        ((S('move') | 'go' | 'drive') % 'go' +
         ((S('to') + ~S('the') +
           loc_syntax % 'place'))) |
        (S('stop') | 'halt' | 'exit') % 'halt' |
        ((S('spin') % 'spin' | S('turn') % 'go') + (S('around') | 'left' | 'right') % 'direction') |
        ((S('say') | 'tell me' | 'speak' | 'what is' | 'what\'s') % 'say' + ~(S('your') | 'a') +
         (S('name') | 'identification' | 'id' | 'hello' | 'hi' | 'joke') % 'info') |
        (S("where are you going") % 'where') |
	((S('take')|S('bring')|S('give')|S('send')) + ~S('a') + S("message") % 'bring_msg' + ~(S('from') + ~S('the') + loc_syntax % 'source') + S('to') + ~S('the') + loc_syntax % 'dest')
    )
    return cmd


if __name__ == '__main__':
    rospy.init_node('speech_interpreter')
    master.register_syntax(get_cmd())
    speech_topic = rospy.get_param('~speech_in', '/recognizer/output')
    active_topic = rospy.get_param('~active', '/face_finder/closest_face')
    planner.init()

    srv = InteractServer(rospy.get_name())
    master.register_fn(srv.set_name)

    textin = rospy.Subscriber(speech_topic, std_msgs.msg.String, callback=srv.speech_callback, callback_args=master)
    check_active = rospy.Subscriber(active_topic, rospy.msg.AnyMsg, callback=face_callback)
    check_voice = rospy.Subscriber('/is_speaking', std_msgs.msg.Bool, callback=voice_callback)

    rospy.spin()