gains.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 namespace hebi {
4 
5 template<typename MessageType,
6  typename FloatFieldType, typename BoolFieldType,
7  typename FloatEnumType, typename BoolEnumType>
8 class Gains final
9 {
10  public:
11  #ifndef DOXYGEN_OMIT_INTERNAL
12  Gains(MessageType internal, FloatEnumType kp_gain, BoolEnumType d_on_error_gain)
14  kp_(internal, kp_gain),
15  ki_(internal, static_cast<FloatEnumType>(kp_gain + 1)),
16  kd_(internal, static_cast<FloatEnumType>(kp_gain + 2)),
17  feed_forward_(internal, static_cast<FloatEnumType>(kp_gain + 3)),
18  dead_zone_(internal, static_cast<FloatEnumType>(kp_gain + 4)),
19  i_clamp_(internal, static_cast<FloatEnumType>(kp_gain + 5)),
20  punch_(internal, static_cast<FloatEnumType>(kp_gain + 6)),
21  min_target_(internal, static_cast<FloatEnumType>(kp_gain + 7)),
22  max_target_(internal, static_cast<FloatEnumType>(kp_gain + 8)),
23  target_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 9)),
24  min_output_(internal, static_cast<FloatEnumType>(kp_gain + 10)),
25  max_output_(internal, static_cast<FloatEnumType>(kp_gain + 11)),
26  output_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 12)),
27  d_on_error_(internal, d_on_error_gain)
28  {
29  }
30  #endif // DOXYGEN_OMIT_INTERNAL
31 
32  // With all submessage and field getters: Note that the returned reference
33  // should not be used after the lifetime of this parent.
34 
35  // Subfields ----------------
36 
38  FloatFieldType& kP() { return kp_; }
40  const FloatFieldType& kP() const { return kp_; }
42  FloatFieldType& kI() { return ki_; }
44  const FloatFieldType& kI() const { return ki_; }
46  FloatFieldType& kD() { return kd_; }
48  const FloatFieldType& kD() const { return kd_; }
50  FloatFieldType& feedForward() { return feed_forward_; }
52  const FloatFieldType& feedForward() const { return feed_forward_; }
54  FloatFieldType& deadZone() { return dead_zone_; }
56  const FloatFieldType& deadZone() const { return dead_zone_; }
58  FloatFieldType& iClamp() { return i_clamp_; }
60  const FloatFieldType& iClamp() const { return i_clamp_; }
62  FloatFieldType& punch() { return punch_; }
64  const FloatFieldType& punch() const { return punch_; }
66  FloatFieldType& minTarget() { return min_target_; }
68  const FloatFieldType& minTarget() const { return min_target_; }
70  FloatFieldType& maxTarget() { return max_target_; }
72  const FloatFieldType& maxTarget() const { return max_target_; }
74  FloatFieldType& targetLowpass() { return target_lowpass_; }
76  const FloatFieldType& targetLowpass() const { return target_lowpass_; }
78  FloatFieldType& minOutput() { return min_output_; }
80  const FloatFieldType& minOutput() const { return min_output_; }
82  FloatFieldType& maxOutput() { return max_output_; }
84  const FloatFieldType& maxOutput() const { return max_output_; }
86  FloatFieldType& outputLowpass() { return output_lowpass_; }
88  const FloatFieldType& outputLowpass() const { return output_lowpass_; }
90  BoolFieldType& dOnError() { return d_on_error_; }
92  const BoolFieldType& dOnError() const { return d_on_error_; }
93 
94  private:
95  MessageType const internal_;
96 
97  FloatFieldType kp_;
98  FloatFieldType ki_;
99  FloatFieldType kd_;
100  FloatFieldType feed_forward_;
101  FloatFieldType dead_zone_;
102  FloatFieldType i_clamp_;
103  FloatFieldType punch_;
104  FloatFieldType min_target_;
105  FloatFieldType max_target_;
106  FloatFieldType target_lowpass_;
107  FloatFieldType min_output_;
108  FloatFieldType max_output_;
109  FloatFieldType output_lowpass_;
110  BoolFieldType d_on_error_;
111 
113 };
114 
115 } // namespace hebi
FloatFieldType & minTarget()
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:66
const FloatFieldType & targetLowpass() const
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: gains.hpp:76
FloatFieldType output_lowpass_
Definition: gains.hpp:109
const FloatFieldType & maxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:84
FloatFieldType min_target_
Definition: gains.hpp:104
const FloatFieldType & kP() const
Proportional PID gain.
Definition: gains.hpp:40
BoolFieldType d_on_error_
Definition: gains.hpp:110
Definition: color.hpp:5
const FloatFieldType & outputLowpass() const
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: gains.hpp:88
const FloatFieldType & minTarget() const
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:68
FloatFieldType feed_forward_
Definition: gains.hpp:100
const FloatFieldType & kD() const
Derivative PID gain.
Definition: gains.hpp:48
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:7
const FloatFieldType & punch() const
Constant offset to the PID output outside of the deadzone; it is added when the error is positive and...
Definition: gains.hpp:64
FloatFieldType & outputLowpass()
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: gains.hpp:86
const FloatFieldType & maxTarget() const
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:72
FloatFieldType punch_
Definition: gains.hpp:103
FloatFieldType & maxTarget()
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:70
const FloatFieldType & deadZone() const
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: gains.hpp:56
FloatFieldType & feedForward()
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:50
FloatFieldType & deadZone()
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: gains.hpp:54
FloatFieldType & kP()
Proportional PID gain.
Definition: gains.hpp:38
FloatFieldType max_target_
Definition: gains.hpp:105
FloatFieldType i_clamp_
Definition: gains.hpp:102
MessageType const internal_
Definition: gains.hpp:95
FloatFieldType target_lowpass_
Definition: gains.hpp:106
FloatFieldType & iClamp()
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: gains.hpp:58
const FloatFieldType & feedForward() const
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:52
FloatFieldType & kD()
Derivative PID gain.
Definition: gains.hpp:46
const FloatFieldType & minOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:80
FloatFieldType ki_
Definition: gains.hpp:98
FloatFieldType min_output_
Definition: gains.hpp:107
FloatFieldType kp_
Definition: gains.hpp:97
FloatFieldType max_output_
Definition: gains.hpp:108
BoolFieldType & dOnError()
Controls whether the Kd term uses the "derivative of error" or "derivative of measurement." When the setpoints have step inputs or are noisy, setting this to false can eliminate corresponding spikes or noise in the output.
Definition: gains.hpp:90
FloatFieldType & minOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:78
Gains(MessageType internal, FloatEnumType kp_gain, BoolEnumType d_on_error_gain)
Definition: gains.hpp:12
const BoolFieldType & dOnError() const
Controls whether the Kd term uses the "derivative of error" or "derivative of measurement." When the setpoints have step inputs or are noisy, setting this to false can eliminate corresponding spikes or noise in the output.
Definition: gains.hpp:92
const FloatFieldType & iClamp() const
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: gains.hpp:60
FloatFieldType & targetLowpass()
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: gains.hpp:74
FloatFieldType & kI()
Integral PID gain.
Definition: gains.hpp:42
FloatFieldType kd_
Definition: gains.hpp:99
FloatFieldType & maxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:82
FloatFieldType dead_zone_
Definition: gains.hpp:101
FloatFieldType & punch()
Constant offset to the PID output outside of the deadzone; it is added when the error is positive and...
Definition: gains.hpp:62
const FloatFieldType & kI() const
Integral PID gain.
Definition: gains.hpp:44


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:12