Go to the documentation of this file.00001
00002
00003 import rospy
00004 import uuid
00005 import unique_id
00006 import world_canvas_msgs.srv
00007
00008 from rospy_message_converter import message_converter
00009
00010
00011 if __name__ == '__main__':
00012 rospy.init_node('set_keyword')
00013
00014 id = rospy.get_param('~id')
00015 keyword = rospy.get_param('~keyword')
00016 action = rospy.get_param('~action')
00017
00018 rospy.loginfo("Waiting for set_keyword service...")
00019 rospy.wait_for_service('set_keyword')
00020
00021 rospy.loginfo("%s keyword %s for annotation %s", "Add" if action == 1 else "Remove", keyword, id)
00022 set_kw_srv = rospy.ServiceProxy('set_keyword', world_canvas_msgs.srv.SetKeyword)
00023 response = set_kw_srv(unique_id.toMsg(uuid.UUID('urn:uuid:' + id)), keyword, action)
00024
00025 if response.result == True:
00026 rospy.loginfo("Keyword %s successfully %s. %s", keyword, "added" if action == 1 else "removed", response.message)
00027 else:
00028 rospy.logerr("%s keyword %s failed; %s", "Add" if action == 1 else "Remove", keyword, response.message)