ros2_control - rolling
traction_limiter.hpp
1 // Copyright 2022 Pixel Robotics.
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 
15 /*
16  * Author: Tony Najjar
17  */
18 
19 #ifndef TRICYCLE_CONTROLLER__TRACTION_LIMITER_HPP_
20 #define TRICYCLE_CONTROLLER__TRACTION_LIMITER_HPP_
21 
22 #include <cmath>
23 
24 namespace tricycle_controller
25 {
27 {
28 public:
52  double min_velocity = NAN, double max_velocity = NAN, double min_acceleration = NAN,
53  double max_acceleration = NAN, double min_deceleration = NAN, double max_deceleration = NAN,
54  double min_jerk = NAN, double max_jerk = NAN);
55 
64  double limit(double & v, double v0, double v1, double dt);
65 
71  double limit_velocity(double & v);
72 
80  double limit_acceleration(double & v, double v0, double dt);
81 
91  double limit_jerk(double & v, double v0, double v1, double dt);
92 
93 private:
94  // Velocity limits:
95  double min_velocity_;
96  double max_velocity_;
97 
98  // Acceleration limits:
99  double min_acceleration_;
100  double max_acceleration_;
101 
102  // Deceleration limits:
103  double min_deceleration_;
104  double max_deceleration_;
105 
106  // Jerk limits:
107  double min_jerk_;
108  double max_jerk_;
109 };
110 
111 } // namespace tricycle_controller
112 
113 #endif // TRICYCLE_CONTROLLER__TRACTION_LIMITER_HPP_
Definition: traction_limiter.hpp:27
double limit(double &v, double v0, double v1, double dt)
Limit the velocity and acceleration.
Definition: traction_limiter.cpp:97
TractionLimiter(double min_velocity=NAN, double max_velocity=NAN, double min_acceleration=NAN, double max_acceleration=NAN, double min_deceleration=NAN, double max_deceleration=NAN, double min_jerk=NAN, double max_jerk=NAN)
Constructor.
Definition: traction_limiter.cpp:27
double limit_velocity(double &v)
Limit the velocity.
Definition: traction_limiter.cpp:109
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
Definition: traction_limiter.cpp:142
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
Definition: traction_limiter.cpp:119