ros2_control - rolling
Loading...
Searching...
No Matches
joint_limits.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__JOINT_LIMITS_HPP_
18#define JOINT_LIMITS__JOINT_LIMITS_HPP_
19
20#include <limits>
21#include <sstream>
22#include <string>
23
24namespace joint_limits
25{
36{
38 : min_position(std::numeric_limits<double>::quiet_NaN()),
39 max_position(std::numeric_limits<double>::quiet_NaN()),
40 max_velocity(std::numeric_limits<double>::quiet_NaN()),
41 max_acceleration(std::numeric_limits<double>::quiet_NaN()),
42 max_deceleration(std::numeric_limits<double>::quiet_NaN()),
43 max_jerk(std::numeric_limits<double>::quiet_NaN()),
44 max_effort(std::numeric_limits<double>::quiet_NaN()),
45 has_position_limits(false),
46 has_velocity_limits(false),
47 has_acceleration_limits(false),
48 has_deceleration_limits(false),
49 has_jerk_limits(false),
50 has_effort_limits(false),
51 angle_wraparound(false)
52 {
53 }
54
55 double min_position;
56 double max_position;
57 double max_velocity;
58 double max_acceleration;
59 double max_deceleration;
60 double max_jerk;
61 double max_effort;
62
63 bool has_position_limits;
64 bool has_velocity_limits;
65 bool has_acceleration_limits;
66 bool has_deceleration_limits;
67 bool has_jerk_limits;
68 bool has_effort_limits;
69 bool angle_wraparound;
70
71 void disable_all_limits()
72 {
73 has_position_limits = false;
74 has_velocity_limits = false;
75 has_acceleration_limits = false;
76 has_deceleration_limits = false;
77 has_jerk_limits = false;
78 has_effort_limits = false;
79 min_position = -std::numeric_limits<double>::max();
80 max_position = std::numeric_limits<double>::max();
81 max_velocity = std::numeric_limits<double>::max();
82 max_acceleration = std::numeric_limits<double>::max();
83 max_deceleration = std::numeric_limits<double>::max();
84 max_jerk = std::numeric_limits<double>::max();
85 max_effort = std::numeric_limits<double>::max();
86 }
87
88 std::string to_string() const
89 {
90 std::stringstream ss_output;
91
92 ss_output << " has position limits: " << (has_position_limits ? "true" : "false") << " ["
93 << min_position << ", " << max_position << "]\n";
94 ss_output << " has velocity limits: " << (has_velocity_limits ? "true" : "false") << " ["
95 << max_velocity << "]\n";
96 ss_output << " has acceleration limits: " << (has_acceleration_limits ? "true" : "false")
97 << " [" << max_acceleration << "]\n";
98 ss_output << " has deceleration limits: " << (has_deceleration_limits ? "true" : "false")
99 << " [" << max_deceleration << "]\n";
100 ss_output << " has jerk limits: " << (has_jerk_limits ? "true" : "false") << " [" << max_jerk
101 << "]\n";
102 ss_output << " has effort limits: " << (has_effort_limits ? "true" : "false") << " ["
103 << max_effort << "]\n";
104 ss_output << " angle wraparound: " << (angle_wraparound ? "true" : "false");
105
106 return ss_output.str();
107 }
108};
109
130{
132 : min_position(std::numeric_limits<double>::quiet_NaN()),
133 max_position(std::numeric_limits<double>::quiet_NaN()),
134 k_position(std::numeric_limits<double>::quiet_NaN()),
135 k_velocity(std::numeric_limits<double>::quiet_NaN())
136 {
137 }
138
139 double min_position;
140 double max_position;
141 double k_position;
142 double k_velocity;
143
144 std::string to_string() const
145 {
146 std::stringstream ss_output;
147
148 ss_output << " soft position limits: "
149 << "[" << min_position << ", " << max_position << "]\n";
150
151 ss_output << " k-position: "
152 << "[" << k_position << "]\n";
153
154 ss_output << " k-velocity: "
155 << "[" << k_velocity << "]\n";
156
157 return ss_output.str();
158 }
159};
160
161} // namespace joint_limits
162
163#endif // JOINT_LIMITS__JOINT_LIMITS_HPP_
Definition data_structures.hpp:39
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