Ignition Math

API Reference

6.8.0
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 IGNITION_MATH_SYSTEMS_SPEEDLIMITER_HH_
19 #define IGNITION_MATH_SYSTEMS_SPEEDLIMITER_HH_
20 
21 #include <chrono>
22 #include <memory>
23 #include <ignition/math/config.hh>
24 #include "ignition/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
Class to limit velocity, acceleration and jerk.
Definition: SpeedLimiter.hh:36
Definition: Angle.hh:42