joint_limits_interface_extension.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Pilz GmbH & Co. KG
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef JOINT_LIMITS_INTERFACE_EXTENSION_H
18 #define JOINT_LIMITS_INTERFACE_EXTENSION_H
19 
22 
23 namespace pilz_extensions {
24 namespace joint_limits_interface {
25 
29 inline bool getJointLimits(const std::string& joint_name,
30  const ros::NodeHandle& nh,
32 
33  // Node handle scoped where the joint limits are
34  // defined (copied from ::joint_limits_interface::getJointLimits(joint_name, nh, limits)
35  ros::NodeHandle limits_nh;
36  try
37  {
38  const std::string limits_namespace = "joint_limits/" + joint_name;
39  if (!nh.hasParam(limits_namespace))
40  {
41  ROS_DEBUG_STREAM("No joint limits specification found for joint '" << joint_name <<
42  "' in the parameter server (namespace " << nh.getNamespace() + "/" + limits_namespace << ").");
43  return false;
44  }
45  limits_nh = ros::NodeHandle(nh, limits_namespace);
46  }
47  catch(const ros::InvalidNameException& ex)
48  {
49  ROS_ERROR_STREAM(ex.what());
50  return false;
51  }
52 
53  // Set the existing limits
54  if(! ::joint_limits_interface::getJointLimits(joint_name, nh, limits)) {
55  return false;
56  }
57 
58  // Deceleration limits
59  bool has_deceleration_limits = false;
60  if(limits_nh.getParam("has_deceleration_limits", has_deceleration_limits))
61  {
62  if (!has_deceleration_limits) {limits.has_deceleration_limits = false;}
63  double max_dec;
64  if (has_deceleration_limits && limits_nh.getParam("max_deceleration", max_dec))
65  {
66  limits.has_deceleration_limits = true;
67  limits.max_deceleration = max_dec;
68  }
69  }
70 
71  return true;
72 }
73 
74 }
75 }
76 
77 #endif // JOINT_LIMITS_INTERFACE_EXTENSION_H
double max_deceleration
maximum deceleration MUST(!) be negative
bool getJointLimits(const std::string &joint_name, const ros::NodeHandle &nh,::pilz_extensions::joint_limits_interface::JointLimits &limits)
const std::string & getNamespace() const
#define ROS_DEBUG_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
Extends joint_limits_interface::JointLimits with a deceleration parameter.
bool hasParam(const std::string &key) const
#define ROS_ERROR_STREAM(args)


pilz_extensions
Author(s):
autogenerated on Mon Apr 6 2020 03:17:24