Gazebo Math

API Reference

7.5.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 gz::math
27 {
28  // Inline bracket to help doxygen filtering.
29  inline namespace GZ_MATH_VERSION_NAMESPACE {
30  // Forward declaration.
31  class SpeedLimiterPrivate;
32 
34  class GZ_MATH_VISIBLE SpeedLimiter
35  {
38  public: SpeedLimiter();
39 
41  public: ~SpeedLimiter();
42 
45  public: void SetMinVelocity(double _lim);
46 
49  public: double MinVelocity() const;
50 
53  public: void SetMaxVelocity(double _lim);
54 
57  public: double MaxVelocity() const;
58 
61  public: void SetMinAcceleration(double _lim);
62 
65  public: double MinAcceleration() const;
66 
69  public: void SetMaxAcceleration(double _lim);
70 
73  public: double MaxAcceleration() const;
74 
77  public: void SetMinJerk(double _lim);
78 
81  public: double MinJerk() const;
82 
85  public: void SetMaxJerk(double _lim);
86 
89  public: double MaxJerk() const;
90 
97  public: double Limit(double &_vel,
98  double _prevVel,
99  double _prevPrevVel,
100  std::chrono::steady_clock::duration _dt) const;
101 
105  public: double LimitVelocity(double &_vel) const;
106 
113  public: double LimitAcceleration(
114  double &_vel,
115  double _prevVel,
116  std::chrono::steady_clock::duration _dt) const;
117 
125  public: double LimitJerk(
126  double &_vel,
127  double _prevVel,
128  double _prevPrevVel,
129  std::chrono::steady_clock::duration _dt) const;
130 
131 #ifdef _WIN32
132 // Disable warning C4251 which is triggered by
133 // std::unique_ptr
134 #pragma warning(push)
135 #pragma warning(disable: 4251)
136 #endif
138  private: std::unique_ptr<SpeedLimiterPrivate> dataPtr;
139 #ifdef _WIN32
140 #pragma warning(pop)
141 #endif
142  };
143  } // namespace GZ_MATH_VERSION_NAMESPACE
144 } // namespace gz::math
145 #endif // GZ_MATH_SYSTEMS_SPEEDLIMITER_HH_