Gazebo Math

API Reference

6.15.1
gz/math/SpeedLimiter.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_MATH_SYSTEMS_SPEEDLIMITER_HH_
19 #define GZ_MATH_SYSTEMS_SPEEDLIMITER_HH_
20 
21 #include <chrono>
22 #include <memory>
23 #include <gz/math/config.hh>
24 #include "gz/math/Helpers.hh"
25 
26 namespace ignition
27 {
28 namespace math
29 {
30 // Inline bracket to help doxygen filtering.
31 inline namespace IGNITION_MATH_VERSION_NAMESPACE {
32  // Forward declaration.
33  class SpeedLimiterPrivate;
34 
36  class IGNITION_MATH_VISIBLE SpeedLimiter
37  {
40  public: SpeedLimiter();
41 
43  public: ~SpeedLimiter();
44 
47  public: void SetMinVelocity(double _lim);
48 
51  public: double MinVelocity() const;
52 
55  public: void SetMaxVelocity(double _lim);
56 
59  public: double MaxVelocity() const;
60 
63  public: void SetMinAcceleration(double _lim);
64 
67  public: double MinAcceleration() const;
68 
71  public: void SetMaxAcceleration(double _lim);
72 
75  public: double MaxAcceleration() const;
76 
79  public: void SetMinJerk(double _lim);
80 
83  public: double MinJerk() const;
84 
87  public: void SetMaxJerk(double _lim);
88 
91  public: double MaxJerk() const;
92 
99  public: double Limit(double &_vel,
100  double _prevVel,
101  double _prevPrevVel,
102  std::chrono::steady_clock::duration _dt) const;
103 
107  public: double LimitVelocity(double &_vel) const;
108 
115  public: double LimitAcceleration(
116  double &_vel,
117  double _prevVel,
118  std::chrono::steady_clock::duration _dt) const;
119 
127  public: double LimitJerk(
128  double &_vel,
129  double _prevVel,
130  double _prevPrevVel,
131  std::chrono::steady_clock::duration _dt) const;
132 
133 #ifdef _WIN32
134 // Disable warning C4251 which is triggered by
135 // std::unique_ptr
136 #pragma warning(push)
137 #pragma warning(disable: 4251)
138 #endif
139  private: std::unique_ptr<SpeedLimiterPrivate> dataPtr;
141 #ifdef _WIN32
142 #pragma warning(pop)
143 #endif
144  };
145  }
146 }
147 }
148 
149 #endif
double LimitVelocity(double &_vel) const
Limit the velocity.
double LimitAcceleration(double &_vel, double _prevVel, std::chrono::steady_clock::duration _dt) const
Limit the acceleration using a first-order backward difference method.
void SetMinVelocity(double _lim)
Set minimum velocity limit in m/s, usually <= 0.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
double MinVelocity() const
Get minimum velocity limit, defaults to negative infinity.
void SetMaxVelocity(double _lim)
Set maximum velocity limit in m/s, usually >= 0.
double MaxVelocity() const
Get maximum velocity limit, defaults to positive infinity.
void SetMaxJerk(double _lim)
Set maximum jerk limit in m/s^3, usually >= 0.
void SetMinJerk(double _lim)
Set minimum jerk limit in m/s^3, usually <= 0.
void SetMaxAcceleration(double _lim)
Set maximum acceleration limit in m/s^2, usually >= 0.
double MaxAcceleration() const
Get maximum acceleration limit, defaults to positive infinity.
Class to limit velocity, acceleration and jerk.
Definition: gz/math/SpeedLimiter.hh:36
SpeedLimiter()
Constructor. There are no limits by default.
double LimitJerk(double &_vel, double _prevVel, double _prevPrevVel, std::chrono::steady_clock::duration _dt) const
Limit the jerk using a second-order backward difference method.
double MinAcceleration() const
Get minimum acceleration limit, defaults to negative infinity.
double MinJerk() const
Get minimum jerk limit, defaults to negative infinity.
double MaxJerk() const
Get maximum jerk limit, defaults to positive infinity.
void SetMinAcceleration(double _lim)
Set minimum acceleration limit in m/s^2, usually <= 0.
double Limit(double &_vel, double _prevVel, double _prevPrevVel, std::chrono::steady_clock::duration _dt) const
Limit velocity, acceleration and jerk.