ros2_control - rolling
steering_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__STEERING_LIMITER_HPP_
20 #define TRICYCLE_CONTROLLER__STEERING_LIMITER_HPP_
21 
22 #include <cmath>
23 
24 namespace tricycle_controller
25 {
27 {
28 public:
39  double min_position = NAN, double max_position = NAN, double min_velocity = NAN,
40  double max_velocity = NAN, double min_acceleration = NAN, double max_acceleration = NAN);
41 
50  double limit(double & p, double p0, double p1, double dt);
51 
60  double limit_position(double & p);
61 
67  double limit_velocity(double & p, double p0, double dt);
68 
76  double limit_acceleration(double & p, double p0, double p1, double dt);
77 
78 private:
79  // Position limits:
80  double min_position_;
81  double max_position_;
82 
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 
92 } // namespace tricycle_controller
93 
94 #endif // TRICYCLE_CONTROLLER__STEERING_LIMITER_HPP_
Definition: steering_limiter.hpp:27
double limit_position(double &p)
Limit the jerk.
Definition: steering_limiter.cpp:75
double limit(double &p, double p0, double p1, double dt)
Limit the position, velocity and acceleration.
Definition: steering_limiter.cpp:63
SteeringLimiter(double min_position=NAN, double max_position=NAN, double min_velocity=NAN, double max_velocity=NAN, double min_acceleration=NAN, double max_acceleration=NAN)
Constructor.
Definition: steering_limiter.cpp:27
double limit_velocity(double &p, double p0, double dt)
Limit the velocity.
Definition: steering_limiter.cpp:83
double limit_acceleration(double &p, double p0, double p1, double dt)
Limit the acceleration.
Definition: steering_limiter.cpp:97