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
70 const JointLimitsStateDataType & current_joint_states,
71 JointLimitsStateDataType & desired_joint_states, const rclcpp::Duration & dt) override;
72
73protected:
74 rclcpp::Clock::SharedPtr clock_;
75 JointLimitsStateDataType prev_command_;
76};
77
78template <typename JointLimitsStateDataType>
80: JointLimiterInterface<JointLimitsStateDataType>()
81{
82 clock_ = std::make_shared<rclcpp::Clock>(rclcpp::Clock(RCL_ROS_TIME));
83}
84
85template <typename JointLimitsStateDataType>
89
90} // namespace joint_limits
91
92#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:79
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....
~JointSaturationLimiter()
Destructor.
Definition joint_saturation_limiter.hpp:86
bool on_init() override
Method is realized by an implementation.
Definition joint_saturation_limiter.hpp:46
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:37