ros2_control - rolling
Loading...
Searching...
No Matches
joint_saturation_limiter.hpp
1// Copyright (c) 2024, PickNik Inc.
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_SATURATION_LIMITER_HPP_
18#define JOINT_LIMITS__JOINT_SATURATION_LIMITER_HPP_
19
20#include <memory>
21#include <vector>
22
23#include "joint_limits/joint_limiter_interface.hpp"
24#include "rclcpp/clock.hpp"
25#include "rclcpp/duration.hpp"
26
27namespace joint_limits
28{
36template <typename JointLimitsStateDataType>
37class JointSaturationLimiter : public JointLimiterInterface<JointLimitsStateDataType>
38{
39public:
42
45
46 bool on_init() override { return true; }
47
48 bool on_configure(const JointLimitsStateDataType & current_joint_states) override
49 {
50 prev_command_ = current_joint_states;
51 return true;
52 }
53
71 const JointLimitsStateDataType & current_joint_states,
72 JointLimitsStateDataType & desired_joint_states, const rclcpp::Duration & dt) override;
73
79 void reset_internals() override
80 {
81 std::lock_guard<std::mutex> lock(mutex_);
82 prev_command_ = JointLimitsStateDataType();
83 }
84
85protected:
86 rclcpp::Clock::SharedPtr clock_;
87 JointLimitsStateDataType prev_command_;
88 std::mutex mutex_;
89};
90
91template <typename JointLimitsStateDataType>
93: JointLimiterInterface<JointLimitsStateDataType>()
94{
95 clock_ = std::make_shared<rclcpp::Clock>(rclcpp::Clock(RCL_ROS_TIME));
96}
97
98template <typename JointLimitsStateDataType>
102
103} // namespace joint_limits
104
105#endif // JOINT_LIMITS__JOINT_SATURATION_LIMITER_HPP_
Definition joint_limiter_interface.hpp:35
Definition joint_saturation_limiter.hpp:38
JointSaturationLimiter()
Constructor.
Definition joint_saturation_limiter.hpp:92
bool on_enforce(const JointLimitsStateDataType &current_joint_states, JointLimitsStateDataType &desired_joint_states, const rclcpp::Duration &dt) override
Enforce joint limits to desired position, velocity and acceleration using clamping....
virtual ~JointSaturationLimiter()
Destructor.
Definition joint_saturation_limiter.hpp:99
bool on_init() override
Method is realized by an implementation.
Definition joint_saturation_limiter.hpp:46
void reset_internals() override
Reset internal states of the limiter.
Definition joint_saturation_limiter.hpp:79
bool on_configure(const JointLimitsStateDataType &current_joint_states) override
Method is realized by an implementation.
Definition joint_saturation_limiter.hpp:48
Definition data_structures.hpp:39