86 const std::string & joint_name,
87 const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & param_itf,
88 const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr & logging_itf)
90 const std::string param_base_name =
"joint_limits." + joint_name;
93 auto_declare<bool>(param_itf, param_base_name +
".has_position_limits",
false);
95 param_itf, param_base_name +
".min_position", std::numeric_limits<double>::quiet_NaN());
97 param_itf, param_base_name +
".max_position", std::numeric_limits<double>::quiet_NaN());
98 auto_declare<bool>(param_itf, param_base_name +
".has_velocity_limits",
false);
100 param_itf, param_base_name +
".min_velocity", std::numeric_limits<double>::quiet_NaN());
101 auto_declare<double>(
102 param_itf, param_base_name +
".max_velocity", std::numeric_limits<double>::quiet_NaN());
103 auto_declare<bool>(param_itf, param_base_name +
".has_acceleration_limits",
false);
104 auto_declare<double>(
105 param_itf, param_base_name +
".max_acceleration", std::numeric_limits<double>::quiet_NaN());
106 auto_declare<bool>(param_itf, param_base_name +
".has_deceleration_limits",
false);
107 auto_declare<double>(
108 param_itf, param_base_name +
".max_deceleration", std::numeric_limits<double>::quiet_NaN());
109 auto_declare<bool>(param_itf, param_base_name +
".has_jerk_limits",
false);
110 auto_declare<double>(
111 param_itf, param_base_name +
".max_jerk", std::numeric_limits<double>::quiet_NaN());
112 auto_declare<bool>(param_itf, param_base_name +
".has_effort_limits",
false);
113 auto_declare<double>(
114 param_itf, param_base_name +
".max_effort", std::numeric_limits<double>::quiet_NaN());
115 auto_declare<bool>(param_itf, param_base_name +
".angle_wraparound",
false);
116 auto_declare<bool>(param_itf, param_base_name +
".has_soft_limits",
false);
117 auto_declare<double>(
118 param_itf, param_base_name +
".k_position", std::numeric_limits<double>::quiet_NaN());
119 auto_declare<double>(
120 param_itf, param_base_name +
".k_velocity", std::numeric_limits<double>::quiet_NaN());
121 auto_declare<double>(
122 param_itf, param_base_name +
".soft_lower_limit", std::numeric_limits<double>::quiet_NaN());
123 auto_declare<double>(
124 param_itf, param_base_name +
".soft_upper_limit", std::numeric_limits<double>::quiet_NaN());
126 catch (
const std::exception & ex)
128 RCLCPP_ERROR(logging_itf->get_logger(),
"%s", ex.what());
227 const std::string & joint_name,
228 const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & param_itf,
229 const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr & logging_itf,
232 const std::string param_base_name =
"joint_limits." + joint_name;
236 !param_itf->has_parameter(param_base_name +
".has_position_limits") &&
237 !param_itf->has_parameter(param_base_name +
".min_position") &&
238 !param_itf->has_parameter(param_base_name +
".max_position") &&
239 !param_itf->has_parameter(param_base_name +
".has_velocity_limits") &&
240 !param_itf->has_parameter(param_base_name +
".min_velocity") &&
241 !param_itf->has_parameter(param_base_name +
".max_velocity") &&
242 !param_itf->has_parameter(param_base_name +
".has_acceleration_limits") &&
243 !param_itf->has_parameter(param_base_name +
".max_acceleration") &&
244 !param_itf->has_parameter(param_base_name +
".has_deceleration_limits") &&
245 !param_itf->has_parameter(param_base_name +
".max_deceleration") &&
246 !param_itf->has_parameter(param_base_name +
".has_jerk_limits") &&
247 !param_itf->has_parameter(param_base_name +
".max_jerk") &&
248 !param_itf->has_parameter(param_base_name +
".has_effort_limits") &&
249 !param_itf->has_parameter(param_base_name +
".max_effort") &&
250 !param_itf->has_parameter(param_base_name +
".angle_wraparound") &&
251 !param_itf->has_parameter(param_base_name +
".has_soft_limits") &&
252 !param_itf->has_parameter(param_base_name +
".k_position") &&
253 !param_itf->has_parameter(param_base_name +
".k_velocity") &&
254 !param_itf->has_parameter(param_base_name +
".soft_lower_limit") &&
255 !param_itf->has_parameter(param_base_name +
".soft_upper_limit"))
258 logging_itf->get_logger(),
259 "No joint limits specification found for joint '%s' in the parameter server "
261 joint_name.c_str(), param_base_name.c_str());
265 catch (
const std::exception & ex)
267 RCLCPP_ERROR(logging_itf->get_logger(),
"%s", ex.what());
272 if (param_itf->has_parameter(param_base_name +
".has_position_limits"))
274 limits.has_position_limits =
275 param_itf->get_parameter(param_base_name +
".has_position_limits").as_bool();
277 limits.has_position_limits && param_itf->has_parameter(param_base_name +
".min_position") &&
278 param_itf->has_parameter(param_base_name +
".max_position"))
280 limits.min_position = param_itf->get_parameter(param_base_name +
".min_position").as_double();
281 limits.max_position = param_itf->get_parameter(param_base_name +
".max_position").as_double();
285 limits.has_position_limits =
false;
289 !limits.has_position_limits &&
290 param_itf->has_parameter(param_base_name +
".angle_wraparound"))
292 limits.angle_wraparound =
293 param_itf->get_parameter(param_base_name +
".angle_wraparound").as_bool();
298 if (param_itf->has_parameter(param_base_name +
".has_velocity_limits"))
300 limits.has_velocity_limits =
301 param_itf->get_parameter(param_base_name +
".has_velocity_limits").as_bool();
302 if (limits.has_velocity_limits && param_itf->has_parameter(param_base_name +
".max_velocity"))
304 limits.max_velocity = param_itf->get_parameter(param_base_name +
".max_velocity").as_double();
308 limits.has_velocity_limits =
false;
313 if (param_itf->has_parameter(param_base_name +
".has_acceleration_limits"))
315 limits.has_acceleration_limits =
316 param_itf->get_parameter(param_base_name +
".has_acceleration_limits").as_bool();
318 limits.has_acceleration_limits &&
319 param_itf->has_parameter(param_base_name +
".max_acceleration"))
321 limits.max_acceleration =
322 param_itf->get_parameter(param_base_name +
".max_acceleration").as_double();
326 limits.has_acceleration_limits =
false;
331 if (param_itf->has_parameter(param_base_name +
".has_deceleration_limits"))
333 limits.has_deceleration_limits =
334 param_itf->get_parameter(param_base_name +
".has_deceleration_limits").as_bool();
336 limits.has_deceleration_limits &&
337 param_itf->has_parameter(param_base_name +
".max_deceleration"))
339 limits.max_deceleration =
340 param_itf->get_parameter(param_base_name +
".max_deceleration").as_double();
344 limits.has_deceleration_limits =
false;
349 if (param_itf->has_parameter(param_base_name +
".has_jerk_limits"))
351 limits.has_jerk_limits =
352 param_itf->get_parameter(param_base_name +
".has_jerk_limits").as_bool();
353 if (limits.has_jerk_limits && param_itf->has_parameter(param_base_name +
".max_jerk"))
355 limits.max_jerk = param_itf->get_parameter(param_base_name +
".max_jerk").as_double();
359 limits.has_jerk_limits =
false;
364 if (param_itf->has_parameter(param_base_name +
".has_effort_limits"))
366 limits.has_effort_limits =
367 param_itf->get_parameter(param_base_name +
".has_effort_limits").as_bool();
368 if (limits.has_effort_limits && param_itf->has_parameter(param_base_name +
".max_effort"))
370 limits.has_effort_limits =
true;
371 limits.max_effort = param_itf->get_parameter(param_base_name +
".max_effort").as_double();
375 limits.has_effort_limits =
false;
457 const std::string & joint_name,
458 const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & param_itf,
459 const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr & logging_itf,
462 const std::string param_base_name =
"joint_limits." + joint_name;
466 !param_itf->has_parameter(param_base_name +
".has_soft_limits") &&
467 !param_itf->has_parameter(param_base_name +
".k_velocity") &&
468 !param_itf->has_parameter(param_base_name +
".k_position") &&
469 !param_itf->has_parameter(param_base_name +
".soft_lower_limit") &&
470 !param_itf->has_parameter(param_base_name +
".soft_upper_limit"))
473 logging_itf->get_logger(),
474 "No soft joint limits specification found for joint '%s' in the parameter server "
476 joint_name.c_str(), param_base_name.c_str());
480 catch (
const std::exception & ex)
482 RCLCPP_ERROR(logging_itf->get_logger(),
"%s", ex.what());
487 if (param_itf->has_parameter(param_base_name +
".has_soft_limits"))
490 param_itf->get_parameter(param_base_name +
".has_soft_limits").as_bool() &&
491 param_itf->has_parameter(param_base_name +
".k_position") &&
492 param_itf->has_parameter(param_base_name +
".k_velocity") &&
493 param_itf->has_parameter(param_base_name +
".soft_lower_limit") &&
494 param_itf->has_parameter(param_base_name +
".soft_upper_limit"))
496 soft_limits.k_position =
497 param_itf->get_parameter(param_base_name +
".k_position").as_double();
498 soft_limits.k_velocity =
499 param_itf->get_parameter(param_base_name +
".k_velocity").as_double();
500 soft_limits.min_position =
501 param_itf->get_parameter(param_base_name +
".soft_lower_limit").as_double();
502 soft_limits.max_position =
503 param_itf->get_parameter(param_base_name +
".soft_upper_limit").as_double();