52 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
bool &value)
55 if (!nh.hasParam(param_name))
57 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
60 nh.getParam(param_name, value);
61 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 67 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶ms_namespace,
68 std::map<std::string, bool> ¶meters)
71 if (!nh.hasParam(params_namespace))
74 << params_namespace <<
"'.");
77 nh.getParam(params_namespace, parameters);
80 for (std::map<std::string, bool>::const_iterator param_it = parameters.begin(); param_it != parameters.end();
83 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << params_namespace <<
"/" 84 << param_it->first <<
"' with value " << param_it->second);
90 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
double &value)
93 if (!nh.hasParam(param_name))
95 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
98 nh.getParam(param_name, value);
99 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 105 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
106 std::vector<double> &values)
109 if (!nh.hasParam(param_name))
111 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
114 nh.getParam(param_name, values);
117 ROS_WARN_STREAM_NAMED(parent_name,
"Empty vector for parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'" 126 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
int &value)
129 if (!nh.hasParam(param_name))
131 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
134 nh.getParam(param_name, value);
135 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 141 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name, std::size_t &value)
144 if (!nh.hasParam(param_name))
146 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
150 nh.getParam(param_name, nonsigned_value);
151 value = nonsigned_value;
152 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 158 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name, std::string &value)
161 if (!nh.hasParam(param_name))
163 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
166 nh.getParam(param_name, value);
167 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 173 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
174 std::vector<std::string> &values)
177 if (!nh.hasParam(param_name))
179 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
182 nh.getParam(param_name, values);
185 ROS_WARN_STREAM_NAMED(parent_name,
"Empty vector for parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'" 188 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 198 if (!nh.hasParam(param_name))
200 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
203 nh.getParam(param_name, temp_value);
204 ROS_DEBUG_STREAM_NAMED(parent_name,
"Loaded parameter '" << nh.getNamespace() <<
"/" << param_name <<
"' with value " 213 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
214 Eigen::Isometry3d &value)
216 std::vector<double> values;
219 if (!nh.hasParam(param_name))
221 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'.");
224 nh.getParam(param_name, values);
227 ROS_WARN_STREAM_NAMED(parent_name,
"Empty vector for parameter '" << nh.getNamespace() <<
"/" << param_name <<
"'" 239 bool get(
const std::string &parent_name,
const ros::NodeHandle &nh,
const std::string ¶m_name,
240 geometry_msgs::Pose &value)
242 Eigen::Isometry3d eigen_pose;
243 if (!
get(parent_name, nh, param_name, eigen_pose))
252 std::stringstream debug_values;
253 for (std::size_t i = 0; i < values.size(); ++i)
255 debug_values << values[i] <<
",";
257 return debug_values.str();
262 std::stringstream debug_values;
263 for (std::size_t i = 0; i < values.size(); ++i)
265 debug_values << values[i] <<
",";
267 return debug_values.str();
270 bool convertDoublesToEigen(
const std::string &parent_name, std::vector<double> values, Eigen::Isometry3d &transform)
272 if (values.size() == 6)
275 Eigen::AngleAxisd roll_angle(values[3], Eigen::Vector3d::UnitX());
276 Eigen::AngleAxisd pitch_angle(values[4], Eigen::Vector3d::UnitY());
277 Eigen::AngleAxisd yaw_angle(values[5], Eigen::Vector3d::UnitZ());
278 Eigen::Quaternion<double> quaternion = roll_angle * pitch_angle * yaw_angle;
280 transform = Eigen::Translation3d(values[0], values[1], values[2]) * quaternion;
284 else if (values.size() == 7)
287 transform = Eigen::Translation3d(values[0], values[1], values[2]) *
288 Eigen::Quaterniond(values[3], values[4], values[5], values[6]);
293 ROS_ERROR_STREAM_NAMED(parent_name,
"Invalid number of doubles provided for transform, size=" << values.size());
303 ROS_ERROR_STREAM_NAMED(parent_name,
"Missing " << error_count <<
" ros parameters that are required. Shutting down " 304 "to prevent undefined behaviors");
bool convertDoublesToEigen(const std::string &parent_name, std::vector< double > values, Eigen::Isometry3d &transform)
Convert from 6 doubles of [x,y,z] [r,p,y] or 7 doubles of [x, y, z, qw, qx, qy, qz] to a transform...
#define ROS_DEBUG_STREAM_NAMED(name, args)
#define ROS_ERROR_STREAM_NAMED(name, args)
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
void shutdownIfError(const std::string &parent_name, std::size_t error_count)
Check that there were no errors, and if there were, shutdown.
ROSCPP_DECL void shutdown()
std::string getDebugArrayString(std::vector< double > values)
Output a string of values from an array for debugging.
#define ROS_WARN_STREAM_NAMED(name, args)