00001 /* 00002 * parameter_server.h 00003 * 00004 */ 00005 #ifndef PARAMETER_SERVER_H_ 00006 #define PARAMETER_SERVER_H_ 00007 #include <string> 00008 #include <ros/ros.h> 00009 #include <boost/any.hpp> 00010 00011 //this is a global definition of the points to be used 00012 //changes to omit color would need adaptations in 00013 //the visualization too 00014 00020 class ParameterServer { 00021 public: 00025 static ParameterServer* instance(); 00026 00034 template<typename T> 00035 T get(const std::string param) { 00036 ROS_ERROR_COND(config.count(param)==0, "ParameterServer object queried for invalid parameter \"%s\"", param.c_str()); 00037 boost::any value = config[param]; 00038 return boost::any_cast<T>(value); 00039 } 00040 00041 private: 00042 std::map<std::string, boost::any> config; 00043 00044 static ParameterServer* _instance; 00045 std::string pre; 00046 ros::NodeHandle handle; 00047 00052 ParameterServer(); 00053 00059 void getValues(); 00060 00064 void defaultConfig(); 00065 00075 template<typename T> 00076 T getFromParameterServer(const std::string param, T def) { 00077 std::string fullParam = param; 00078 T result; 00079 handle.param(fullParam, result, def); 00080 return result; 00081 } 00082 }; 00083 00084 #endif /* PARAMETER_SERVER_H_ */