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:
41  double min_velocity = NAN, double max_velocity = NAN, double min_acceleration = NAN,
42  double max_acceleration = NAN, double min_deceleration = NAN, double max_deceleration = NAN,
43  double min_jerk = NAN, double max_jerk = NAN);
44 
53  double limit(double & v, double v0, double v1, double dt);
54 
60  double limit_velocity(double & v);
61 
69  double limit_acceleration(double & v, double v0, double dt);
70 
80  double limit_jerk(double & v, double v0, double v1, double dt);
81 
82 private:
83  // Velocity limits:
84  double min_velocity_;
85  double max_velocity_;
86 
87  // Acceleration limits:
88  double min_acceleration_;
89  double max_acceleration_;
90 
91  // Deceleration limits:
92  double min_deceleration_;
93  double max_deceleration_;
94 
95  // Jerk limits:
96  double min_jerk_;
97  double max_jerk_;
98 };
99 
100 } // namespace tricycle_controller
101 
102 #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:77
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:89
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
Definition: traction_limiter.cpp:122
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
Definition: traction_limiter.cpp:99