qb_device_joint_limits_resources.h
Go to the documentation of this file.
1 /***
2  * Software License Agreement: BSD 3-Clause License
3  *
4  * Copyright (c) 2016-2018, qbrobotics®
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
8  * following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef QB_DEVICE_JOINT_LIMITS_RESOURCES_H
29 #define QB_DEVICE_JOINT_LIMITS_RESOURCES_H
30 
42  public:
48 
53 
55 
59  void enforceLimits(const ros::Duration &period) {
60 // if (has_soft_limits_) {
61 // joint_position_soft_limits_.enforceLimits(period);
62 // }
63 // else if (has_limits_) {
64  if (has_limits_) {
66  }
67  }
69 
79  for (int i=0; i<joints.names.size(); i++) {
80  // limits specified in the URDF model overwrite existing values in 'limits' and 'soft_limits'
81  // limits specified in the parameter server overwrite existing values in 'limits'
82  // limits not specified preserve their existing values
83  auto urdf_joint = urdf_model.getJoint(joints.names.at(i));
84  const bool urdf_has_limits = joint_limits_interface::getJointLimits(urdf_joint, joints.limits.at(i));
85  const bool urdf_has_soft_limits = joint_limits_interface::getSoftJointLimits(urdf_joint, joints.soft_limits.at(i));
86  const bool rosparam_has_limits = getJointLimits(joints.names.at(i), robot_hw_nh, joints.limits.at(i));
87  const bool rosparam_has_soft_limits = getSoftJointLimits(joints.names.at(i), robot_hw_nh, joints.soft_limits.at(i));
88  has_limits_ = urdf_has_limits || rosparam_has_limits;
89  has_soft_limits_ = urdf_has_soft_limits || rosparam_has_soft_limits;
90 
91  const hardware_interface::JointHandle joint_handle(joint_position.getHandle(joints.names.at(i)));
92  if (has_soft_limits_) {
93  //TODO: add soft limits
94 // const PositionJointSoftLimitsHandle soft_limits_handle(joint_handle, &joints.limits.at(i), joints.soft_limits.at(i));
95 // joint_position_soft_limits_.registerHandle(soft_limits_handle);
96  }
97  else if (has_limits_) {
98  const PositionJointSaturationHandle saturation_handle(joint_handle, &joints.limits.at(i));
99  joint_position_saturation_.registerHandle(saturation_handle);
100  }
101  }
102  }
103 
104  private:
107  // the position limits interface takes care of the position and velocity limits, but not of the effort ones; however
108  // the current is automatically saturated by low level control on the device. The custom interface is aimed to manage
109  // the shaft limits which depends on the variable stiffness preset, i.e. they are not a priori fixed.
111 // PositionJointSoftLimitsInterface joint_position_soft_limits; //TODO: actually not yet implemented
112 };
113 } // namespace qb_device_joint_limits_interface
114 
115 #endif // QB_DEVICE_JOINT_LIMITS_RESOURCES_H
A handle used to enforce position and velocity limits of a position-controlled joint.
void initialize(ros::NodeHandle &robot_hw_nh, qb_device_hardware_interface::qbDeviceHWResources &joints, const urdf::Model &urdf_model, hardware_interface::PositionJointInterface &joint_position)
Retrieve the joint limits for each given joint.
bool getSoftJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, SoftJointLimits &soft_limits)
The qbrobotics Device HardWare Resources contains vectors of named joints.
void enforceLimits(const ros::Duration &period)
std::vector< joint_limits_interface::SoftJointLimits > soft_limits
bool getJointLimits(const std::string &joint_name, const ros::NodeHandle &nh, JointLimits &limits)
bool getSoftJointLimits(urdf::JointConstSharedPtr urdf_joint, SoftJointLimits &soft_limits)
void enforceLimits(const ros::Duration &period)
Enforce limits for all managed interfaces.
The qbrobotics Device Joint Limits Resources is a simple class aimed to group all the joint_limits_in...
JointHandle getHandle(const std::string &name)
bool getJointLimits(urdf::JointConstSharedPtr urdf_joint, JointLimits &limits)
A handle used to enforce position and velocity limits of a position-controlled joint that does not ha...
std::vector< joint_limits_interface::JointLimits > limits


qb_device_hardware_interface
Author(s): qbrobotics®
autogenerated on Thu Jun 6 2019 19:46:29