ros2_control - rolling
Loading...
Searching...
No Matches
joint_limits_helpers.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_HELPERS_HPP_
18#define JOINT_LIMITS__JOINT_LIMITS_HELPERS_HPP_
19
20#include <optional>
21#include <string>
22#include "joint_limits/data_structures.hpp"
23#include "joint_limits/joint_limits.hpp"
24
25namespace joint_limits
26{
27namespace internal
28{
29constexpr double POSITION_BOUNDS_TOLERANCE = 0.002;
30// 0.5 degrees (or) approx. 1 cm for the prismatic joint
31constexpr double OUT_OF_BOUNDS_EXCEPTION_TOLERANCE = 0.0087;
32} // namespace internal
33
40 const JointControlInterfacesData & desired, JointControlInterfacesData & prev_command);
41
49bool is_limited(double value, double min, double max);
50
62PositionLimits compute_position_limits(
63 const std::string & joint_name, const joint_limits::JointLimits & limits,
64 const std::optional<double> & act_vel, const std::optional<double> & act_pos,
65 const std::optional<double> & prev_command_pos, double dt);
66
77VelocityLimits compute_velocity_limits(
78 const std::string & joint_name, const joint_limits::JointLimits & limits,
79 const double & desired_vel, const std::optional<double> & act_pos,
80 const std::optional<double> & prev_command_vel, double dt);
81
92EffortLimits compute_effort_limits(
93 const joint_limits::JointLimits & limits, const std::optional<double> & act_pos,
94 const std::optional<double> & act_vel, double /*dt*/);
95
104AccelerationLimits compute_acceleration_limits(
105 const JointLimits & limits, double desired_acceleration, std::optional<double> actual_velocity);
106
107} // namespace joint_limits
108
109#endif // JOINT_LIMITS__JOINT_LIMITS_HELPERS_HPP_
Definition data_structures.hpp:38
PositionLimits compute_position_limits(const std::string &joint_name, const joint_limits::JointLimits &limits, const std::optional< double > &act_vel, const std::optional< double > &act_pos, const std::optional< double > &prev_command_pos, double dt)
Compute the position limits based on the velocity and acceleration limits.
Definition joint_limits_helpers.cpp:106
VelocityLimits compute_velocity_limits(const std::string &joint_name, const joint_limits::JointLimits &limits, const double &desired_vel, const std::optional< double > &act_pos, const std::optional< double > &prev_command_vel, double dt)
Compute the velocity limits based on the position and acceleration limits.
Definition joint_limits_helpers.cpp:141
EffortLimits compute_effort_limits(const joint_limits::JointLimits &limits, const std::optional< double > &act_pos, const std::optional< double > &act_vel, double)
Computes the effort limits based on the position and velocity limits.
Definition joint_limits_helpers.cpp:202
bool is_limited(double value, double min, double max)
Check if a value is limited by the given limits.
Definition joint_limits_helpers.cpp:104
AccelerationLimits compute_acceleration_limits(const JointLimits &limits, double desired_acceleration, std::optional< double > actual_velocity)
Compute the acceleration limits based on the change in velocity and acceleration and deceleration lim...
Definition joint_limits_helpers.cpp:239
void update_prev_command(const JointControlInterfacesData &desired, JointControlInterfacesData &prev_command)
Update the previous command with the desired command.
Definition joint_limits_helpers.cpp:78
Store joint limits values from YAML definition or URDF <limits> tag.
Definition joint_limits.hpp:36