Go to the documentation of this file.00001 import rospy
00002
00003 from json import loads, dumps
00004 from httplib import CannotSendRequest, ResponseNotReady
00005
00006
00007 """ Methods to interact with the param server. Values have to be passed
00008 as JSON in order to facilitate dynamically typed SRV messages """
00009
00010
00011 def set_param(name, value):
00012 d = None
00013 try:
00014 d = loads(value)
00015 except ValueError:
00016 raise Exception("Due to the type flexibility of the ROS parameter server, the value argument to set_param must be a JSON-formatted string.")
00017 rospy.set_param(name, d)
00018
00019
00020 def get_param(name, default):
00021 d = None
00022 if default is not "":
00023 try:
00024 d = loads(default)
00025 except ValueError:
00026 d = default
00027
00028 return dumps(get_param_obsessively(name, d))
00029
00030 def get_param_obsessively(name, d):
00031
00032 try:
00033 return rospy.get_param(name, d)
00034 except CannotSendRequest, ResponseNotReady:
00035 return get_param_obsessively(name, d)
00036
00037 def has_param(name):
00038 return rospy.has_param(name)
00039
00040
00041 def delete_param(name):
00042 if has_param(name):
00043 rospy.delete_param(name)
00044
00045
00046 def search_param(name):
00047 return rospy.search_param(name)
00048
00049 def get_param_names():
00050 return rospy.get_param_names()