ros2_control - humble
Loading...
Searching...
No Matches
joint_limits_urdf.hpp
1// Copyright 2020 PAL Robotics S.L.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
17#ifndef JOINT_LIMITS_INTERFACE__JOINT_LIMITS_URDF_HPP_
18#define JOINT_LIMITS_INTERFACE__JOINT_LIMITS_URDF_HPP_
19
20#include <urdf/urdfdom_compatibility.h>
21#include <urdf_model/joint.h>
22#include <joint_limits_interface/joint_limits.hpp>
23#include <rclcpp/rclcpp.hpp>
24
26{
34inline bool getJointLimits(urdf::JointConstSharedPtr urdf_joint, JointLimits & limits)
35{
36 if (!urdf_joint || !urdf_joint->limits)
37 {
38 return false;
39 }
40
41 limits.has_position_limits =
42 urdf_joint->type == urdf::Joint::REVOLUTE || urdf_joint->type == urdf::Joint::PRISMATIC;
43 if (limits.has_position_limits)
44 {
45 limits.min_position = urdf_joint->limits->lower;
46 limits.max_position = urdf_joint->limits->upper;
47 }
48
49 if (!limits.has_position_limits && urdf_joint->type == urdf::Joint::CONTINUOUS)
50 {
51 limits.angle_wraparound = true;
52 }
53
54 limits.has_velocity_limits = true;
55 limits.max_velocity = urdf_joint->limits->velocity;
56
57 limits.has_acceleration_limits = false;
58
59 limits.has_effort_limits = true;
60 limits.max_effort = urdf_joint->limits->effort;
61
62 return true;
63}
64
71inline bool getSoftJointLimits(urdf::JointConstSharedPtr urdf_joint, SoftJointLimits & soft_limits)
72{
73 if (!urdf_joint || !urdf_joint->safety)
74 {
75 return false;
76 }
77
78 soft_limits.min_position = urdf_joint->safety->soft_lower_limit;
79 soft_limits.max_position = urdf_joint->safety->soft_upper_limit;
80 soft_limits.k_position = urdf_joint->safety->k_position;
81 soft_limits.k_velocity = urdf_joint->safety->k_velocity;
82
83 return true;
84}
85
86} // namespace joint_limits_interface
87
88#endif // JOINT_LIMITS_INTERFACE__JOINT_LIMITS_URDF_HPP_
Definition joint_limits_interface.hpp:37
bool getSoftJointLimits(urdf::JointConstSharedPtr urdf_joint, SoftJointLimits &soft_limits)
Definition joint_limits_urdf.hpp:71
bool getJointLimits(urdf::JointConstSharedPtr urdf_joint, JointLimits &limits)
Definition joint_limits_urdf.hpp:34