speed_limiter.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, PAL Robotics, S.L.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the PAL Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /*
36  * Author: Enrique Fernández
37  */
38 
39 #pragma once
40 
41 
42 namespace diff_drive_controller
43 {
44 
45  class SpeedLimiter
46  {
47  public:
48 
62  bool has_velocity_limits = false,
63  bool has_acceleration_limits = false,
64  bool has_jerk_limits = false,
65  double min_velocity = 0.0,
66  double max_velocity = 0.0,
67  double min_acceleration = 0.0,
68  double max_acceleration = 0.0,
69  double min_jerk = 0.0,
70  double max_jerk = 0.0
71  );
72 
81  double limit(double& v, double v0, double v1, double dt);
82 
88  double limit_velocity(double& v);
89 
97  double limit_acceleration(double& v, double v0, double dt);
98 
108  double limit_jerk(double& v, double v0, double v1, double dt);
109 
110  public:
111  // Enable/Disable velocity/acceleration/jerk limits:
112  bool has_velocity_limits;
114  bool has_jerk_limits;
115 
116  // Velocity limits:
117  double min_velocity;
118  double max_velocity;
119 
120  // Acceleration limits:
121  double min_acceleration;
122  double max_acceleration;
123 
124  // Jerk limits:
125  double min_jerk;
126  double max_jerk;
127  };
128 
129 } // namespace diff_drive_controller
diff_drive_controller::SpeedLimiter::limit
double limit(double &v, double v0, double v1, double dt)
Limit the velocity and acceleration.
Definition: speed_limiter.cpp:75
diff_drive_controller::SpeedLimiter::SpeedLimiter
SpeedLimiter(bool has_velocity_limits=false, bool has_acceleration_limits=false, bool has_jerk_limits=false, double min_velocity=0.0, double max_velocity=0.0, double min_acceleration=0.0, double max_acceleration=0.0, double min_jerk=0.0, double max_jerk=0.0)
Constructor.
Definition: speed_limiter.cpp:52
diff_drive_controller::SpeedLimiter::limit_velocity
double limit_velocity(double &v)
Limit the velocity.
Definition: speed_limiter.cpp:86
diff_drive_controller
Definition: diff_drive_controller.h:56
diff_drive_controller::SpeedLimiter::min_velocity
double min_velocity
Definition: speed_limiter.h:181
diff_drive_controller::SpeedLimiter::limit_jerk
double limit_jerk(double &v, double v0, double v1, double dt)
Limit the jerk.
Definition: speed_limiter.cpp:115
diff_drive_controller::SpeedLimiter::max_velocity
double max_velocity
Definition: speed_limiter.h:182
diff_drive_controller::SpeedLimiter::has_jerk_limits
bool has_jerk_limits
Definition: speed_limiter.h:178
diff_drive_controller::SpeedLimiter::max_jerk
double max_jerk
Definition: speed_limiter.h:190
diff_drive_controller::SpeedLimiter::has_acceleration_limits
bool has_acceleration_limits
Definition: speed_limiter.h:177
diff_drive_controller::SpeedLimiter::max_acceleration
double max_acceleration
Definition: speed_limiter.h:186
diff_drive_controller::SpeedLimiter::min_acceleration
double min_acceleration
Definition: speed_limiter.h:185
diff_drive_controller::SpeedLimiter::has_velocity_limits
bool has_velocity_limits
Definition: speed_limiter.h:176
diff_drive_controller::SpeedLimiter::min_jerk
double min_jerk
Definition: speed_limiter.h:189
diff_drive_controller::SpeedLimiter::limit_acceleration
double limit_acceleration(double &v, double v0, double dt)
Limit the acceleration.
Definition: speed_limiter.cpp:98


diff_drive_controller
Author(s): Bence Magyar
autogenerated on Fri May 24 2024 02:41:05