1 #ifndef SWRI_ROSCPP_PARAMETERS_H_
2 #define SWRI_ROSCPP_PARAMETERS_H_
9 #include <boost/bind.hpp>
23 const std::string &
name,
30 ROS_ERROR(
"Required int parameter %s does not exist",
name.c_str());
33 ROS_INFO(
"Read parameter %s = %d",
name.c_str(), variable);
39 const std::string &
name,
46 ROS_ERROR(
"Required double parameter %s does not exist",
name.c_str());
49 ROS_INFO(
"Read parameter %s = %lf",
name.c_str(), variable);
55 const std::string &
name,
61 ROS_ERROR(
"Required double parameter %s does not exist",
name.c_str());
65 ROS_INFO(
"Read parameter %s = %f",
name.c_str(), variable);
71 const std::string &
name,
72 std::string &variable)
78 ROS_ERROR(
"Required string parameter %s does not exist",
name.c_str());
81 ROS_INFO(
"Read parameter %s = %s",
name.c_str(), variable.c_str());
87 const std::string &
name,
94 ROS_ERROR(
"Required bool parameter %s does not exist",
name.c_str());
97 ROS_INFO(
"Read parameter %s = %s",
name.c_str(), variable ?
"true" :
"false");
103 const std::string &
name,
105 const int default_value)
110 ROS_INFO(
"Read parameter %s = %d",
name.c_str(), variable);
115 const std::string &
name,
117 const double default_value)
122 ROS_INFO(
"Read parameter %s = %lf",
name.c_str(), variable);
127 const std::string &
name,
129 const float default_value)
134 variable = dbl_value;
135 ROS_INFO(
"Read parameter %s = %f",
name.c_str(), variable);
140 const std::string &
name,
141 std::string &variable,
142 const std::string default_value)
147 ROS_INFO(
"Read parameter %s = \"%s\"",
name.c_str(), variable.c_str());
152 const std::string &
name,
154 const bool default_value)
159 ROS_INFO(
"Read parameter %s = %s",
name.c_str(), variable ?
"true" :
"false");
172 inline int comparePrefix(std::string
const&
string, std::string
const& prefix)
174 return string.compare(0, prefix.size(), prefix);
186 inline bool isPrefixOf(std::string
const&
string, std::string
const& prefix)
228 std::vector<std::string> all_params;
232 std::sort(all_params.begin(), all_params.end());
236 boost::function<bool(std::string)> inNamespace = boost::bind(
isPrefixOf, _1, n_namespace);
238 std::vector<std::string>::const_iterator first_param_in_namespace = find_if(all_params.begin(), all_params.end(), inNamespace);
240 std::vector<std::string>::const_iterator after_last_param_in_namespace = find_if(all_params.begin(), all_params.end(), std::not1(inNamespace));
245 std::vector<std::string> unused_params(all_params.size());
248 std::vector<std::string>::iterator last_unused_param = std::set_difference(
249 first_param_in_namespace, after_last_param_in_namespace,
251 unused_params.begin(),
256 unused_params.resize(last_unused_param - unused_params.begin());
258 return unused_params;
270 for (std::vector<std::string>::const_iterator itr = unused_params.begin(); itr != unused_params.end(); ++itr)
272 ROS_WARN(
"Parameter %s was set, but not used by this node", itr->c_str());
276 #endif // SWRI_ROSCPP_PARAMETERS_H_