Go to the documentation of this file.00001 #ifndef __GET_PARAMS_FROM_SERVER_H
00002 #define __GET_PARAMS_FROM_SERVER_H
00003
00004 #include <string>
00005 #include "ros/ros.h"
00006
00007 bool hasParam(const std::string& name)
00008 {
00009 return ros::param::has(std::string("~")+name);
00010 }
00011
00012 template<typename T>
00013 T getParam(const std::string& name, const T& defaultValue)
00014 {
00015 T v;
00016 if (ros::param::get(std::string("~")+name, v))
00017 {
00018 ROS_INFO_STREAM("Found parameter: " << name << ", value: " << v);
00019 return v;
00020 }
00021 else
00022 ROS_WARN_STREAM("Cannot find value for parameter: " << name << ", assigning default: " << defaultValue);
00023 return defaultValue;
00024 }
00025
00026 template<typename T>
00027 T getParam(const std::string& name)
00028 {
00029 T v;
00030 if (ros::param::get(std::string("~")+name, v))
00031 {
00032 ROS_INFO_STREAM("Found parameter: " << name << ", value: " << v);
00033 return v;
00034 }
00035 else
00036 ROS_ERROR_STREAM("Cannot find value for parameter: " << name);
00037 return T();
00038 }
00039
00040 #endif // __GET_PARAMS_FROM_SERVER_H