feedback.cpp
Go to the documentation of this file.
1 #include "feedback.hpp"
2 #include <cmath>
3 #include <limits>
4 #ifndef M_PI
5 #define M_PI 3.14159265358979323846
6 #endif
7 
8 namespace hebi {
9 
11  : internal_(internal), field_(field)
12 {
13 }
14 
15 Feedback::FloatField::operator bool() const
16 {
17  return has();
18 }
19 
21 {
23 }
24 
26 {
27  float ret;
29  {
30  ret = std::numeric_limits<float>::quiet_NaN();
31  }
32  return ret;
33 }
34 
36  : internal_(internal), field_(field)
37 {
38 }
39 
40 Feedback::HighResAngleField::operator bool() const
41 {
42  return has();
43 }
44 
46 {
47  return (hebiFeedbackGetHighResAngle(internal_, field_, nullptr, nullptr) == HebiStatusSuccess);
48 }
49 
51 {
52  int64_t revolutions;
53  float radian_offset;
54  if (hebiFeedbackGetHighResAngle(internal_, field_, &revolutions, &radian_offset) != HebiStatusSuccess)
55  {
56  return std::numeric_limits<double>::quiet_NaN();
57  }
58  return (
59  static_cast<double>(revolutions) * 2.0 * M_PI +
60  static_cast<double>(radian_offset)
61  );
62 }
63 
64 void Feedback::HighResAngleField::get(int64_t* revolutions, float* radian_offset) const
65 {
66  if (hebiFeedbackGetHighResAngle(internal_, field_, revolutions, radian_offset) != HebiStatusSuccess)
67  {
68  *revolutions = 0;
69  *radian_offset = std::numeric_limits<float>::quiet_NaN();
70  }
71 }
72 
74  : internal_(internal), field_(field)
75 {
76 }
77 
78 bool Feedback::NumberedFloatField::has(size_t fieldNumber) const
79 {
80  return (hebiFeedbackGetNumberedFloat(internal_, field_, fieldNumber, nullptr) == HebiStatusSuccess);
81 }
82 
83 float Feedback::NumberedFloatField::get(size_t fieldNumber) const
84 {
85  float ret;
87  {
88  ret = std::numeric_limits<float>::quiet_NaN();
89  }
90  return ret;
91 }
92 
94  : internal_(internal), field_(field)
95 {
96 }
97 
98 Feedback::UInt64Field::operator bool() const
99 {
100  return has();
101 }
102 
104 {
106 }
107 
109 {
110  uint64_t ret;
112  {
113  ret = 0;
114  }
115  return ret;
116 }
117 
119  : internal_(internal), field_(field)
120 {
121 }
122 
123 Feedback::Vector3fField::operator bool() const
124 {
125  return has();
126 }
127 
129 {
131 }
132 
134 {
135  HebiVector3f ret;
137  {
138  ret.x = std::numeric_limits<float>::quiet_NaN();
139  ret.y = std::numeric_limits<float>::quiet_NaN();
140  ret.z = std::numeric_limits<float>::quiet_NaN();
141  }
142  return ret;
143 }
144 
146  : internal_(internal), field_(field) {}
147 
148 Feedback::QuaternionfField::operator bool() const
149 {
150  return has();
151 }
152 
154 {
156 }
157 
159 {
160  HebiQuaternionf ret;
162  ret.w = std::numeric_limits<float>::quiet_NaN();
163  ret.x = std::numeric_limits<float>::quiet_NaN();
164  ret.y = std::numeric_limits<float>::quiet_NaN();
165  ret.z = std::numeric_limits<float>::quiet_NaN();
166  }
167  return ret;
168 }
169 
171  : internal_(internal), bank_(bank)
172 {
173 }
174 
175 bool Feedback::IoBank::hasInt(size_t pinNumber) const
176 {
177  return (hebiFeedbackGetIoPinInt(internal_, bank_, pinNumber, nullptr) == HebiStatusSuccess);
178 }
179 
180 bool Feedback::IoBank::hasFloat(size_t pinNumber) const
181 {
182  return (hebiFeedbackGetIoPinFloat(internal_, bank_, pinNumber, nullptr) == HebiStatusSuccess);
183 }
184 
185 int64_t Feedback::IoBank::getInt(size_t pinNumber) const
186 {
187  int64_t ret;
188  hebiFeedbackGetIoPinInt(internal_, bank_, pinNumber, &ret);
189  return ret;
190 }
191 
192 float Feedback::IoBank::getFloat(size_t pinNumber) const
193 {
194  float ret;
195  hebiFeedbackGetIoPinFloat(internal_, bank_, pinNumber, &ret);
196  return ret;
197 }
198 
200  : internal_(internal), field_(field)
201 {
202 }
203 
205 {
206  return (hebiFeedbackGetLedColor(internal_, field_, nullptr, nullptr, nullptr) == HebiStatusSuccess);
207 }
208 
210 {
211  uint8_t r, g, b;
213  {
214  r = 0;
215  g = 0;
216  b = 0;
217  }
218  return Color(r, g, b);
219 }
220 
222  : internal_(feedback),
223  io_(internal_),
225  imu_(internal_),
231 {
232 }
234 {
235 }
236 
238  : internal_(other.internal_),
239  io_(internal_),
241  imu_(internal_),
247 {
248  // NOTE: it would be nice to also cleanup the actual internal pointer of other
249  // but alas we cannot change a const variable.
250 }
251 
253 {
254  return board_temperature_;
255 }
257 {
258  return processor_temperature_;
259 }
261 {
262  return voltage_;
263 }
265 {
266  return debug_;
267 }
269 {
270  return led_;
271 }
272 
273 } // namespace hebi
Ambient temperature inside the module (measured at the IMU chip), in degrees Celsius.
Definition: hebi.h:130
HebiFeedbackQuaternionfField
Definition: hebi.h:169
HebiFeedbackPtr const internal_
Definition: feedback.hpp:424
float x
Definition: hebi.h:425
FloatField processor_temperature_
Definition: feedback.hpp:699
HebiFeedbackIoPinBank const bank_
Definition: feedback.hpp:394
bool hasInt(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an integer (e.g., digital) value.
Definition: feedback.cpp:175
const NumberedFloatField & debug() const
Values for internal debug functions (channel 1-9 available).
Definition: feedback.cpp:264
float getFloat(size_t pinNumber) const
If this numbered pin in this bank has an floating point (e.g., analog or PWM) value, returns that value; otherwise returns a default.
Definition: feedback.cpp:192
HighResAngleField(HebiFeedbackPtr internal, HebiFeedbackHighResAngleField field)
Definition: feedback.cpp:35
FloatField board_temperature_
Definition: feedback.hpp:698
Structure to hold a 3-D floating point vector (i.e., x/y/z components)
Definition: vector_3_f.hpp:8
Feedback(HebiFeedbackPtr)
Wraps an existing C-style object that is managed by its parent. NOTE: this should not be used except ...
Definition: feedback.cpp:221
HebiFeedbackVector3fField
Definition: hebi.h:164
FloatField voltage_
Definition: feedback.hpp:700
QuaternionfField(HebiFeedbackPtr internal, HebiFeedbackQuaternionfField field)
Definition: feedback.cpp:145
const FloatField & boardTemperature() const
Ambient temperature inside the module (measured at the IMU chip), in degrees Celsius.
Definition: feedback.cpp:252
HebiFeedbackPtr const internal_
Definition: feedback.hpp:191
~Feedback() noexcept
Cleans up feedback object as necessary.
Definition: feedback.cpp:233
HebiFeedbackHighResAngleField
Definition: hebi.h:146
bool has() const
True if (and only if) the field has a value.
Definition: feedback.cpp:45
LedField led_
Definition: feedback.hpp:702
NumberedFloatField(HebiFeedbackPtr internal, HebiFeedbackNumberedFloatField field)
Definition: feedback.cpp:73
HebiFeedbackPtr const internal_
Definition: feedback.hpp:140
Definition: color.hpp:5
FloatField(HebiFeedbackPtr internal, HebiFeedbackFloatField field)
Definition: feedback.cpp:10
HebiStatusCode hebiFeedbackGetIoPinInt(HebiFeedbackPtr fbk, HebiFeedbackIoPinBank field, size_t pin_number, int64_t *value)
HebiFeedbackNumberedFloatField
Definition: hebi.h:151
HebiStatusCode hebiFeedbackGetLedColor(HebiFeedbackPtr fbk, HebiFeedbackLedField field, uint8_t *r, uint8_t *g, uint8_t *b)
HebiFeedbackLedField
Definition: hebi.h:191
Structure to hold a floating point quaternion (i.e., w/x/y/z components)
Definition: quaternion_f.hpp:8
Vector3f get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: feedback.cpp:133
UInt64Field(HebiFeedbackPtr internal, HebiFeedbackUInt64Field field)
Definition: feedback.cpp:93
bool has() const
True if (and only if) the field has a value.
Definition: feedback.cpp:128
NumberedFloatField debug_
Definition: feedback.hpp:701
HebiFeedbackFloatField
Definition: hebi.h:128
int64_t getInt(size_t pinNumber) const
If this numbered pin in this bank has an integer (e.g., digital) value, returns that value; otherwise...
Definition: feedback.cpp:185
HebiFeedbackLedField const field_
Definition: feedback.hpp:425
HebiFeedbackUInt64Field const field_
Definition: feedback.hpp:253
Vector3fField(HebiFeedbackPtr internal, HebiFeedbackVector3fField field)
Definition: feedback.cpp:118
HebiFeedbackVector3fField const field_
Definition: feedback.hpp:286
float z
Definition: hebi.h:427
HebiStatusCode hebiFeedbackGetUInt64(HebiFeedbackPtr fbk, HebiFeedbackUInt64Field field, uint64_t *value)
float y
Definition: hebi.h:426
A message field representable by a single-precision floating point value.
Definition: feedback.hpp:114
Feedback objects have various fields representing feedback from modules; which fields are populated d...
Definition: feedback.hpp:30
float get(size_t fieldNumber) const
If the particular numbered subvalue of this field has a value, returns that value; otherwise returns ...
Definition: feedback.cpp:83
HebiFeedbackPtr const internal_
Definition: feedback.hpp:252
HebiStatusCode hebiFeedbackGetVector3f(HebiFeedbackPtr fbk, HebiFeedbackVector3fField field, HebiVector3f *value)
double get() const
If the field has a value, returns that value as a double; otherwise, returns a default.
Definition: feedback.cpp:50
HebiFeedbackPtr const internal_
Definition: feedback.hpp:393
const LedField & led() const
The module&#39;s LED.
Definition: feedback.cpp:268
#define M_PI
Definition: hebi.h:12
bool has() const
True if (and only if) the field has a value.
Definition: feedback.cpp:20
bool hasFloat(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an floating point (e...
Definition: feedback.cpp:180
HebiFeedbackUInt64Field
Definition: hebi.h:155
HebiStatusCode hebiFeedbackGetFloat(HebiFeedbackPtr fbk, HebiFeedbackFloatField field, float *value)
bool hasColor() const
Returns true if the LED color is set, and false otherwise.
Definition: feedback.cpp:204
HebiFeedbackHighResAngleField const field_
Definition: feedback.hpp:192
IoBank(HebiFeedbackPtr internal, HebiFeedbackIoPinBank bank)
Definition: feedback.cpp:170
A message field for interfacing with an LED.
Definition: feedback.hpp:399
const FloatField & voltage() const
Bus voltage that the module is running at (in Volts).
Definition: feedback.cpp:260
bool has() const
True if (and only if) the field has a value.
Definition: feedback.cpp:153
HebiFeedbackPtr const internal_
Definition: feedback.hpp:318
bool has() const
True if (and only if) the field has a value.
Definition: feedback.cpp:103
HebiStatusCode hebiFeedbackGetQuaternionf(HebiFeedbackPtr fbk, HebiFeedbackQuaternionfField field, HebiQuaternionf *value)
bool has(size_t fieldNumber) const
True if (and only if) the particular numbered subvalue of this field has a value. ...
Definition: feedback.cpp:78
struct _HebiFeedback * HebiFeedbackPtr
The C-style&#39;s API representation of feedback.
Definition: hebi.h:322
float get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: feedback.cpp:25
HebiStatusCode hebiFeedbackGetHighResAngle(HebiFeedbackPtr fbk, HebiFeedbackHighResAngleField field, int64_t *int_part, float *dec_part)
Actuator actuator_
Definition: feedback.hpp:695
const FloatField & processorTemperature() const
Temperature of the processor chip, in degrees Celsius.
Definition: feedback.cpp:256
Temperature of the processor chip, in degrees Celsius.
Definition: hebi.h:131
HebiFeedbackPtr const internal_
Definition: feedback.hpp:219
HebiStatusCode hebiFeedbackGetIoPinFloat(HebiFeedbackPtr fbk, HebiFeedbackIoPinBank field, size_t pin_number, float *value)
HebiFeedbackFloatField const field_
Definition: feedback.hpp:141
HebiStatusCode hebiFeedbackGetNumberedFloat(HebiFeedbackPtr fbk, HebiFeedbackNumberedFloatField field, size_t number, float *value)
HebiFeedbackQuaternionfField const field_
Definition: feedback.hpp:319
Quaternionf get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: feedback.cpp:158
uint64_t get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: feedback.cpp:108
HebiFeedbackPtr const internal_
Definition: feedback.hpp:285
Structure to describe an RGB color.
Definition: color.hpp:8
HebiFeedbackNumberedFloatField const field_
Definition: feedback.hpp:220
EIGEN_DEVICE_FUNC const Scalar & b
HebiFeedbackIoPinBank
Definition: hebi.h:182
Color getColor() const
Returns the led color.
Definition: feedback.cpp:209
A message field containing a numbered set of single-precision floating point values.
Definition: feedback.hpp:199
LedField(HebiFeedbackPtr internal, HebiFeedbackLedField field)
Definition: feedback.cpp:199
HebiFeedbackPtr internal_
Definition: feedback.hpp:647


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