HEBI C++ API  2.2.0
gains.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "util.hpp"
4 
5 namespace hebi {
6 
7 template<typename MessageType, typename FloatFieldType, typename BoolFieldType, typename FloatEnumType,
8  typename BoolEnumType>
9 class Gains final {
10 public:
11 #ifndef DOXYGEN_OMIT_INTERNAL
12  Gains(MessageType internal, FloatEnumType kp_gain, BoolEnumType d_on_error_gain)
13  : internal_(internal),
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 #endif // DOXYGEN_OMIT_INTERNAL
29 
30  // With all submessage and field getters: Note that the returned reference
31  // should not be used after the lifetime of this parent.
32 
33  // Subfields ----------------
34 
36  FloatFieldType& kP() { return kp_; }
38  const FloatFieldType& kP() const { return kp_; }
40  FloatFieldType& kI() { return ki_; }
42  const FloatFieldType& kI() const { return ki_; }
44  FloatFieldType& kD() { return kd_; }
46  const FloatFieldType& kD() const { return kd_; }
48  FloatFieldType& feedForward() { return feed_forward_; }
50  const FloatFieldType& feedForward() const { return feed_forward_; }
53  FloatFieldType& deadZone() { return dead_zone_; }
56  const FloatFieldType& deadZone() const { return dead_zone_; }
59  FloatFieldType& iClamp() { return i_clamp_; }
62  const FloatFieldType& iClamp() const { return i_clamp_; }
65  FloatFieldType& punch() { return punch_; }
68  const FloatFieldType& punch() const { return punch_; }
70  FloatFieldType& minTarget() { return min_target_; }
72  const FloatFieldType& minTarget() const { return min_target_; }
74  FloatFieldType& maxTarget() { return max_target_; }
76  const FloatFieldType& maxTarget() const { return max_target_; }
79  FloatFieldType& targetLowpass() { return target_lowpass_; }
82  const FloatFieldType& targetLowpass() const { return target_lowpass_; }
84  FloatFieldType& minOutput() { return min_output_; }
86  const FloatFieldType& minOutput() const { return min_output_; }
88  FloatFieldType& maxOutput() { return max_output_; }
90  const FloatFieldType& maxOutput() const { return max_output_; }
93  FloatFieldType& outputLowpass() { return output_lowpass_; }
96  const FloatFieldType& outputLowpass() const { return output_lowpass_; }
99  BoolFieldType& dOnError() { return d_on_error_; }
102  const BoolFieldType& dOnError() const { return d_on_error_; }
103 
104 private:
105  MessageType const internal_;
106 
107  FloatFieldType kp_;
108  FloatFieldType ki_;
109  FloatFieldType kd_;
110  FloatFieldType feed_forward_;
111  FloatFieldType dead_zone_;
112  FloatFieldType i_clamp_;
113  FloatFieldType punch_;
114  FloatFieldType min_target_;
115  FloatFieldType max_target_;
116  FloatFieldType target_lowpass_;
117  FloatFieldType min_output_;
118  FloatFieldType max_output_;
119  FloatFieldType output_lowpass_;
120  BoolFieldType d_on_error_;
121 
123 };
124 
125 } // namespace hebi
FloatFieldType & minTarget()
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:70
const FloatFieldType & iClamp() const
Definition: gains.hpp:62
const FloatFieldType & minOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:86
const FloatFieldType & targetLowpass() const
Definition: gains.hpp:82
const FloatFieldType & kI() const
Integral PID gain.
Definition: gains.hpp:42
const FloatFieldType & feedForward() const
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:50
const FloatFieldType & maxTarget() const
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:76
Definition: gains.hpp:9
Definition: color.hpp:5
const FloatFieldType & maxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:90
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:6
FloatFieldType & outputLowpass()
Definition: gains.hpp:93
FloatFieldType & maxTarget()
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:74
FloatFieldType & feedForward()
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:48
FloatFieldType & deadZone()
Definition: gains.hpp:53
FloatFieldType & kP()
Proportional PID gain.
Definition: gains.hpp:36
const FloatFieldType & kP() const
Proportional PID gain.
Definition: gains.hpp:38
FloatFieldType & iClamp()
Definition: gains.hpp:59
FloatFieldType & kD()
Derivative PID gain.
Definition: gains.hpp:44
const BoolFieldType & dOnError() const
Definition: gains.hpp:102
const FloatFieldType & punch() const
Definition: gains.hpp:68
const FloatFieldType & minTarget() const
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:72
BoolFieldType & dOnError()
Definition: gains.hpp:99
FloatFieldType & minOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:84
FloatFieldType & targetLowpass()
Definition: gains.hpp:79
const FloatFieldType & kD() const
Derivative PID gain.
Definition: gains.hpp:46
FloatFieldType & kI()
Integral PID gain.
Definition: gains.hpp:40
const FloatFieldType & deadZone() const
Definition: gains.hpp:56
const FloatFieldType & outputLowpass() const
Definition: gains.hpp:96
FloatFieldType & maxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:88
FloatFieldType & punch()
Definition: gains.hpp:65