ros2_control - rolling
Loading...
Searching...
No Matches
joint_limits_urdf.hpp
1// Copyright 2024 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__JOINT_LIMITS_URDF_HPP_
18#define JOINT_LIMITS__JOINT_LIMITS_URDF_HPP_
19
20#include "joint_limits/joint_limits.hpp"
21#include "urdf_model/joint.h"
22
23namespace joint_limits
24{
25
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 = std::abs(urdf_joint->limits->velocity);
56
57 limits.has_acceleration_limits = false;
58
59 limits.has_effort_limits = true;
60 limits.max_effort = std::abs(urdf_joint->limits->effort);
61
62 return true;
63}
64
72inline bool getSoftJointLimits(urdf::JointConstSharedPtr urdf_joint, SoftJointLimits & soft_limits)
73{
74 if (!urdf_joint || !urdf_joint->safety)
75 {
76 return false;
77 }
78
79 soft_limits.min_position = urdf_joint->safety->soft_lower_limit;
80 soft_limits.max_position = urdf_joint->safety->soft_upper_limit;
81 soft_limits.k_position = urdf_joint->safety->k_position;
82 soft_limits.k_velocity = urdf_joint->safety->k_velocity;
83
84 return true;
85}
86} // namespace joint_limits
87#endif // JOINT_LIMITS__JOINT_LIMITS_URDF_HPP_
Definition data_structures.hpp:39
bool getSoftJointLimits(urdf::JointConstSharedPtr urdf_joint, SoftJointLimits &soft_limits)
Populate a SoftJointLimits instance from URDF joint data.
Definition joint_limits_urdf.hpp:72
bool getJointLimits(urdf::JointConstSharedPtr urdf_joint, JointLimits &limits)
Populate a JointLimits instance from URDF joint data.
Definition joint_limits_urdf.hpp:34
Store joint limits values from YAML definition or URDF <limits> tag.
Definition joint_limits.hpp:36
Store soft joint limits values from the URDF <safety_controller> tag.
Definition joint_limits.hpp:130