7 #include <boost/algorithm/string.hpp> 11 using is_vector = std::is_same<T, std::vector<typename T::value_type, typename T::allocator_type>>;
15 using is_map = std::is_same<
16 T, std::map<typename T::key_type, typename T::mapped_type, typename T::key_compare, typename T::allocator_type>>;
21 inline std::string
to_string(
const std::vector<T>& v)
27 std::copy(v.begin(), v.end(), std::ostream_iterator<T>(ss,
", "));
34 template <
typename... T>
35 inline std::string
to_string(
const std::map<T...>& map)
39 for (
typename std::map<T...>::const_iterator it = map.begin(); it != map.end(); ++it) {
40 ss << (*it).first <<
" --> " << (*it).second <<
", ";
51 std::string verbosity;
52 if (!nodeHandle.
getParam(
"verbosity", verbosity)) {
53 verbosity =
"warning";
57 bool valid_verbosity{
true};
58 if (verbosity ==
"debug") {
60 }
else if (verbosity ==
"info") {
62 }
else if (verbosity ==
"warning") {
64 }
else if (verbosity ==
"error") {
66 }
else if (verbosity ==
"fatal") {
69 ROS_WARN_STREAM(
"Invalid verbosity level specified: " << verbosity <<
"! Falling back to INFO.");
70 valid_verbosity =
false;
72 if (valid_verbosity) {
85 std::vector<std::string> subscribed_topics, advertised_topics;
89 std::ostringstream msg_subscr, msg_advert;
90 for (
auto const& t : subscribed_topics) {
91 msg_subscr << t <<
"\n";
93 for (
auto const& t : advertised_topics) {
94 msg_advert << t <<
"\n";
98 <<
"Subscribed topics:\n" 99 << msg_subscr.str() <<
"Advertised topics:\n" 100 << msg_advert.str());
109 std::string name_space = privateNodeHandle.
getNamespace();
110 std::stringstream tempString(name_space);
112 while (std::getline(tempString, name,
'/')) {
119 inline void exit(
const std::string msg =
"Runtime Error in rosparam handler.") {
121 throw std::runtime_error(msg);
128 template <
typename T>
129 inline void setParam(
const std::string key, T val) {
137 template <
typename T>
138 inline bool getParam(
const std::string key, T& val) {
143 ROS_ERROR_STREAM(
"Could not retrieve parameter'" << key <<
"'. Does it have a different type?");
156 template <
typename T>
157 inline bool getParam(
const std::string key, T& val,
const T& defaultValue) {
161 ROS_INFO_STREAM(
"Setting default value for parameter '" << key <<
"'.");
173 <<
"' was set on the parameter server eventhough it was defined to be constant.");
185 template <
typename T>
186 inline void testMin(
const std::string key, T& val, T min = std::numeric_limits<T>::min()) {
189 <<
" is smaller than minimal allowed value. Correcting value to min=" << min);
199 template <
typename T>
200 inline void testMin(
const std::string key, std::vector<T>& val, T min = std::numeric_limits<T>::min()) {
210 template <
typename K,
typename T>
211 inline void testMin(
const std::string key, std::map<K, T>& val, T min = std::numeric_limits<T>::min()) {
221 template <
typename T>
222 inline void testMax(
const std::string key, T& val, T max = std::numeric_limits<T>::max()) {
225 <<
" is greater than maximal allowed. Correcting value to max=" << max);
235 template <
typename T>
236 inline void testMax(
const std::string key, std::vector<T>& val, T max = std::numeric_limits<T>::max()) {
246 template <
typename K,
typename T>
247 inline void testMax(
const std::string key, std::map<K, T>& val, T max = std::numeric_limits<T>::max()) {
void exit(const std::string msg="Runtime Error in rosparam handler.")
ExitFunction for rosparam_handler.
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
void testMin(const std::string key, T &val, T min=std::numeric_limits< T >::min())
Limit parameter to lower bound if parameter is a scalar.
void setParam(const std::string key, T val)
Set parameter on ROS parameter server.
std::string getNodeName(const ros::NodeHandle &privateNodeHandle)
Retrieve node name.
std::string to_string(const std::vector< T > &v)
std::is_same< T, std::vector< typename T::value_type, typename T::allocator_type >> is_vector
Helper function to test for std::vector.
std::string getName(void *handle)
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
bool testConstParam(const std::string key)
Tests that parameter is not set on the parameter server.
ROSCPP_DECL const std::string & getNamespace()
void showNodeInfo()
Show summary about node containing name, namespace, subscribed and advertised topics.
ROSCPP_DECL bool get(const std::string &key, std::string &s)
ROSCPP_DECL void getSubscribedTopics(V_string &topics)
const std::string & getNamespace() const
ROSCPP_DECL bool has(const std::string &key)
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
void testMax(const std::string key, T &val, T max=std::numeric_limits< T >::max())
Limit parameter to upper bound if parameter is a scalar.
ROSCPP_DECL void getAdvertisedTopics(V_string &topics)
std::is_same< T, std::map< typename T::key_type, typename T::mapped_type, typename T::key_compare, typename T::allocator_type >> is_map
Helper function to test for std::map.
bool getParam(const std::string key, T &val)
Get parameter from ROS parameter server.
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
#define ROS_ERROR_STREAM(args)
#define ROSCONSOLE_DEFAULT_NAME
void setLoggerLevel(const ros::NodeHandle &nodeHandle)
Sets the logger level according to a standardized parameter name 'verbosity'.