HEBI C++ API  3.9.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 MessageRefType, typename FloatFieldType, typename BoolFieldType, typename FloatEnumType,
8  typename BoolEnumType>
9 class Gains final {
10 public:
11 #ifndef DOXYGEN_OMIT_INTERNAL
12  Gains(MessageRefType& internal, FloatEnumType kp_gain, BoolEnumType d_on_error_gain)
13  : kp_(internal, kp_gain),
14  ki_(internal, static_cast<FloatEnumType>(kp_gain + 1)),
15  kd_(internal, static_cast<FloatEnumType>(kp_gain + 2)),
16  feed_forward_(internal, static_cast<FloatEnumType>(kp_gain + 3)),
17  dead_zone_(internal, static_cast<FloatEnumType>(kp_gain + 4)),
18  i_clamp_(internal, static_cast<FloatEnumType>(kp_gain + 5)),
19  punch_(internal, static_cast<FloatEnumType>(kp_gain + 6)),
20  min_target_(internal, static_cast<FloatEnumType>(kp_gain + 7)),
21  max_target_(internal, static_cast<FloatEnumType>(kp_gain + 8)),
22  target_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 9)),
23  min_output_(internal, static_cast<FloatEnumType>(kp_gain + 10)),
24  max_output_(internal, static_cast<FloatEnumType>(kp_gain + 11)),
25  output_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 12)),
26  d_on_error_(internal, d_on_error_gain) {}
27  Gains(const MessageRefType& internal, FloatEnumType kp_gain, BoolEnumType d_on_error_gain)
28  : kp_(internal, kp_gain),
29  ki_(internal, static_cast<FloatEnumType>(kp_gain + 1)),
30  kd_(internal, static_cast<FloatEnumType>(kp_gain + 2)),
31  feed_forward_(internal, static_cast<FloatEnumType>(kp_gain + 3)),
32  dead_zone_(internal, static_cast<FloatEnumType>(kp_gain + 4)),
33  i_clamp_(internal, static_cast<FloatEnumType>(kp_gain + 5)),
34  punch_(internal, static_cast<FloatEnumType>(kp_gain + 6)),
35  min_target_(internal, static_cast<FloatEnumType>(kp_gain + 7)),
36  max_target_(internal, static_cast<FloatEnumType>(kp_gain + 8)),
37  target_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 9)),
38  min_output_(internal, static_cast<FloatEnumType>(kp_gain + 10)),
39  max_output_(internal, static_cast<FloatEnumType>(kp_gain + 11)),
40  output_lowpass_(internal, static_cast<FloatEnumType>(kp_gain + 12)),
41  d_on_error_(internal, d_on_error_gain) {}
42 #endif // DOXYGEN_OMIT_INTERNAL
43 
44  // With all submessage and field getters: Note that the returned reference
45  // should not be used after the lifetime of this parent.
46 
47  // Subfields ----------------
48 
50  FloatFieldType& kP() { return kp_; }
52  const FloatFieldType& kP() const { return kp_; }
54  FloatFieldType& kI() { return ki_; }
56  const FloatFieldType& kI() const { return ki_; }
58  FloatFieldType& kD() { return kd_; }
60  const FloatFieldType& kD() const { return kd_; }
62  FloatFieldType& feedForward() { return feed_forward_; }
64  const FloatFieldType& feedForward() const { return feed_forward_; }
67  FloatFieldType& deadZone() { return dead_zone_; }
70  const FloatFieldType& deadZone() const { return dead_zone_; }
73  FloatFieldType& iClamp() { return i_clamp_; }
76  const FloatFieldType& iClamp() const { return i_clamp_; }
79  FloatFieldType& punch() { return punch_; }
82  const FloatFieldType& punch() const { return punch_; }
84  FloatFieldType& minTarget() { return min_target_; }
86  const FloatFieldType& minTarget() const { return min_target_; }
88  FloatFieldType& maxTarget() { return max_target_; }
90  const FloatFieldType& maxTarget() const { return max_target_; }
93  FloatFieldType& targetLowpass() { return target_lowpass_; }
96  const FloatFieldType& targetLowpass() const { return target_lowpass_; }
98  FloatFieldType& minOutput() { return min_output_; }
100  const FloatFieldType& minOutput() const { return min_output_; }
102  FloatFieldType& maxOutput() { return max_output_; }
104  const FloatFieldType& maxOutput() const { return max_output_; }
107  FloatFieldType& outputLowpass() { return output_lowpass_; }
110  const FloatFieldType& outputLowpass() const { return output_lowpass_; }
113  BoolFieldType& dOnError() { return d_on_error_; }
116  const BoolFieldType& dOnError() const { return d_on_error_; }
117 
118 private:
119  FloatFieldType kp_;
120  FloatFieldType ki_;
121  FloatFieldType kd_;
122  FloatFieldType feed_forward_;
123  FloatFieldType dead_zone_;
124  FloatFieldType i_clamp_;
125  FloatFieldType punch_;
126  FloatFieldType min_target_;
127  FloatFieldType max_target_;
128  FloatFieldType target_lowpass_;
129  FloatFieldType min_output_;
130  FloatFieldType max_output_;
131  FloatFieldType output_lowpass_;
132  BoolFieldType d_on_error_;
133 
135 };
136 
137 } // namespace hebi
FloatFieldType & outputLowpass()
Definition: gains.hpp:107
const FloatFieldType & kP() const
Proportional PID gain.
Definition: gains.hpp:52
FloatFieldType & minOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:98
FloatFieldType & targetLowpass()
Definition: gains.hpp:93
FloatFieldType & kP()
Proportional PID gain.
Definition: gains.hpp:50
const FloatFieldType & kI() const
Integral PID gain.
Definition: gains.hpp:56
const FloatFieldType & minTarget() const
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:86
Definition: gains.hpp:9
Definition: arm.cpp:8
const FloatFieldType & minOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: gains.hpp:100
FloatFieldType & deadZone()
Definition: gains.hpp:67
const FloatFieldType & targetLowpass() const
Definition: gains.hpp:96
FloatFieldType & punch()
Definition: gains.hpp:79
const FloatFieldType & maxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:104
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:6
BoolFieldType & dOnError()
Definition: gains.hpp:113
const FloatFieldType & punch() const
Definition: gains.hpp:82
const FloatFieldType & maxTarget() const
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:90
FloatFieldType & kD()
Derivative PID gain.
Definition: gains.hpp:58
FloatFieldType & minTarget()
Minimum allowed value for input to the PID controller.
Definition: gains.hpp:84
FloatFieldType & iClamp()
Definition: gains.hpp:73
FloatFieldType & maxTarget()
Maximum allowed value for input to the PID controller.
Definition: gains.hpp:88
FloatFieldType & feedForward()
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:62
FloatFieldType & kI()
Integral PID gain.
Definition: gains.hpp:54
const FloatFieldType & kD() const
Derivative PID gain.
Definition: gains.hpp:60
const BoolFieldType & dOnError() const
Definition: gains.hpp:116
const FloatFieldType & feedForward() const
Feed forward term (this term is multiplied by the target and added to the output).
Definition: gains.hpp:64
const FloatFieldType & outputLowpass() const
Definition: gains.hpp:110
FloatFieldType & maxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: gains.hpp:102
const FloatFieldType & iClamp() const
Definition: gains.hpp:76
const FloatFieldType & deadZone() const
Definition: gains.hpp:70