ros2_control - rolling
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 
27 namespace joint_limits
28 {
36 template <typename LimitsType>
38 {
39 public:
41  JOINT_LIMITS_PUBLIC JointSaturationLimiter();
42 
44  JOINT_LIMITS_PUBLIC ~JointSaturationLimiter();
45 
46  JOINT_LIMITS_PUBLIC bool on_init() override { return true; }
47 
48  JOINT_LIMITS_PUBLIC bool on_configure(
49  const trajectory_msgs::msg::JointTrajectoryPoint & /*current_joint_states*/) override
50  {
51  return true;
52  }
53 
69  JOINT_LIMITS_PUBLIC bool on_enforce(
70  trajectory_msgs::msg::JointTrajectoryPoint & current_joint_states,
71  trajectory_msgs::msg::JointTrajectoryPoint & desired_joint_states,
72  const rclcpp::Duration & dt) override;
73 
83  JOINT_LIMITS_PUBLIC bool on_enforce(std::vector<double> & desired_joint_states) override;
84 
85 private:
86  rclcpp::Clock::SharedPtr clock_;
87 };
88 
89 template <typename LimitsType>
91 {
92  clock_ = std::make_shared<rclcpp::Clock>(rclcpp::Clock(RCL_ROS_TIME));
93 }
94 
95 template <typename LimitsType>
97 {
98 }
99 
100 } // namespace joint_limits
101 
102 #endif // JOINT_LIMITS__JOINT_SATURATION_LIMITER_HPP_
Definition: joint_limiter_interface.hpp:36
Definition: joint_saturation_limiter.hpp:38
JOINT_LIMITS_PUBLIC bool on_enforce(trajectory_msgs::msg::JointTrajectoryPoint &current_joint_states, trajectory_msgs::msg::JointTrajectoryPoint &desired_joint_states, const rclcpp::Duration &dt) override
Enforce joint limits to desired position, velocity and acceleration using clamping....
JOINT_LIMITS_PUBLIC bool on_enforce(std::vector< double > &desired_joint_states) override
Enforce joint limits to desired arbitrary physical quantity. Additional, commonly used method for enf...
JOINT_LIMITS_PUBLIC bool on_configure(const trajectory_msgs::msg::JointTrajectoryPoint &) override
Method is realized by an implementation.
Definition: joint_saturation_limiter.hpp:48
JOINT_LIMITS_PUBLIC ~JointSaturationLimiter()
Destructor.
Definition: joint_saturation_limiter.hpp:96
JOINT_LIMITS_PUBLIC bool on_init() override
Method is realized by an implementation.
Definition: joint_saturation_limiter.hpp:46
JOINT_LIMITS_PUBLIC JointSaturationLimiter()
Constructor.
Definition: joint_saturation_limiter.hpp:90
Definition: joint_limiter_interface.hpp:31