Skip to content

Commit

Permalink
Add get(..) overload for vector of bool.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavanderhoorn committed Feb 17, 2019
1 parent 743f9d6 commit f7fdbdf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/rosparam_shortcuts/rosparam_shortcuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::s
bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name,
std::vector<double> &values);

bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name,
std::vector<bool> &values);

bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name, int &value);

bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name, std::size_t &value);
Expand Down
21 changes: 21 additions & 0 deletions src/rosparam_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::s
return true;
}

bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name,
std::vector<bool> &values)
{
// Load a param
if (!nh.hasParam(param_name))
{
ROS_ERROR_STREAM_NAMED(parent_name, "Missing parameter '" << nh.getNamespace() << "/" << param_name << "'.");
return false;
}
nh.getParam(param_name, values);

if (values.empty())
ROS_WARN_STREAM_NAMED(parent_name, "Empty vector for parameter '" << nh.getNamespace() << "/" << param_name << "'"
".");

ROS_DEBUG_STREAM_NAMED(parent_name, "Loaded parameter '" << nh.getNamespace() << "/" << param_name
<< "' with values [" << getDebugArrayString(values) << "]");

return true;
}

bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string &param_name, int &value)
{
// Load a param
Expand Down

0 comments on commit f7fdbdf

Please sign in to comment.