ros2_control - rolling
Loading...
Searching...
No Matches
speed_limiter.hpp
1// Copyright 2020 PAL Robotics S.L.
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: Enrique Fernández
17 */
18
19#ifndef DIFF_DRIVE_CONTROLLER__SPEED_LIMITER_HPP_
20#define DIFF_DRIVE_CONTROLLER__SPEED_LIMITER_HPP_
21
22#include <limits>
23
24#include "control_toolbox/rate_limiter.hpp"
25
26namespace diff_drive_controller
27{
29{
30public:
49 explicit SpeedLimiter(
50 double min_velocity, double max_velocity, double max_acceleration_reverse,
51 double max_acceleration, double max_deceleration, double max_deceleration_reverse,
52 double min_jerk, double max_jerk)
53 {
55 min_velocity, max_velocity, max_acceleration_reverse, max_acceleration, max_deceleration,
56 max_deceleration_reverse, min_jerk, max_jerk);
57 }
58
67 double limit(double & v, double v0, double v1, double dt)
68 {
69 return speed_limiter_.limit(v, v0, v1, dt);
70 }
71
77 double limit_velocity(double & v) { return speed_limiter_.limit_value(v); }
78
86 double limit_acceleration(double & v, double v0, double dt)
87 {
88 return speed_limiter_.limit_first_derivative(v, v0, dt);
89 }
90
100 double limit_jerk(double & v, double v0, double v1, double dt)
101 {
102 return speed_limiter_.limit_second_derivative(v, v0, v1, dt);
103 }
104
105private:
106 control_toolbox::RateLimiter<double> speed_limiter_; // Instance of the new RateLimiter
107};
108
109} // namespace diff_drive_controller
110
111#endif // DIFF_DRIVE_CONTROLLER__SPEED_LIMITER_HPP_
A Low-pass filter class.
Definition low_pass_filter.hpp:79
T limit_value(T &v)
Limit the value.
Definition rate_limiter.hpp:251
T limit_second_derivative(T &v, T v0, T v1, T dt)
Limit the second_derivative.
Definition rate_limiter.hpp:295
T limit(T &v, T v0, T v1, T dt)
Limit the value, first_derivative, and second_derivative.
Definition rate_limiter.hpp:239
T limit_first_derivative(T &v, T v0, T dt)
Limit the first_derivative.
Definition rate_limiter.hpp:264
Definition speed_limiter.hpp:29
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
Definition speed_limiter.hpp:100
double limit(double &v, double v0, double v1, double dt)
Limit the velocity, acceleration, and jerk.
Definition speed_limiter.hpp:67
SpeedLimiter(double min_velocity, double max_velocity, double max_acceleration_reverse, double max_acceleration, double max_deceleration, double max_deceleration_reverse, double min_jerk, double max_jerk)
Constructor.
Definition speed_limiter.hpp:49
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
Definition speed_limiter.hpp:86
double limit_velocity(double &v)
Limit the velocity.
Definition speed_limiter.hpp:77