Gazebo Math

API Reference

7.4.0
gz/math/PID.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 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#ifndef GZ_MATH_PID_HH_
18#define GZ_MATH_PID_HH_
19
20#include <chrono>
21#include <gz/math/Helpers.hh>
22#include <gz/math/config.hh>
23#include <gz/utils/ImplPtr.hh>
24
25namespace gz
26{
27 namespace math
28 {
29 // Inline bracket to help doxygen filtering.
30 inline namespace GZ_MATH_VERSION_NAMESPACE {
31 //
38 // cppcheck-suppress class_X_Y
39 class GZ_MATH_VISIBLE PID
40 {
58 public: PID(const double _p = 0.0,
59 const double _i = 0.0,
60 const double _d = 0.0,
61 const double _imax = -1.0,
62 const double _imin = 0.0,
63 const double _cmdMax = -1.0,
64 const double _cmdMin = 0.0,
65 const double _cmdOffset = 0.0);
66
84 public: void Init(const double _p = 0.0,
85 const double _i = 0.0,
86 const double _d = 0.0,
87 const double _imax = -1.0,
88 const double _imin = 0.0,
89 const double _cmdMax = -1.0,
90 const double _cmdMin = 0.0,
91 const double _cmdOffset = 0.0);
92
95 public: void SetPGain(const double _p);
96
99 public: void SetIGain(const double _i);
100
103 public: void SetDGain(const double _d);
104
107 public: void SetIMax(const double _i);
108
111 public: void SetIMin(const double _i);
112
115 public: void SetCmdMax(const double _c);
116
119 public: void SetCmdMin(const double _c);
120
124 public: void SetCmdOffset(const double _c);
125
128 public: double PGain() const;
129
132 public: double IGain() const;
133
136 public: double DGain() const;
137
140 public: double IMax() const;
141
144 public: double IMin() const;
145
148 public: double CmdMax() const;
149
152 public: double CmdMin() const;
153
156 public: double CmdOffset() const;
157
169 public: double Update(const double _error,
170 double _errorRate,
172
180 public: double Update(const double _error,
182
185 public: void SetCmd(const double _cmd);
186
189 public: double Cmd() const;
190
195 public: void Errors(double &_pe, double &_ie, double &_de) const;
196
198 public: void Reset();
199
201 GZ_UTILS_IMPL_PTR(dataPtr)
202 };
203 }
204 }
205}
206#endif