info.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "hebi.h"
4 #include "color.hpp"
5 #include <string>
6 #include "util.hpp"
7 #include "gains.hpp"
8 
9 namespace hebi {
10 
30 class Info final
31 {
32  public:
33  enum class ControlStrategy {
35  Off,
37  DirectPWM,
39  Strategy2,
41  Strategy3,
43  Strategy4,
44  };
45 
46  enum class CalibrationState {
48  Normal,
50  UncalibratedCurrent,
52  UncalibratedPosition,
54  UncalibratedEffort,
55  };
56 
57  // Note: this is 'protected' instead of 'private' for easier use with Doxygen
58  protected:
60  class FloatField final
61  {
62  public:
63  #ifndef DOXYGEN_OMIT_INTERNAL
64  FloatField(HebiInfoPtr internal, HebiInfoFloatField field);
65  #endif // DOXYGEN_OMIT_INTERNAL
66  explicit operator bool() const;
80  bool has() const;
83  float get() const;
84 
85  private:
88 
90  };
96  class HighResAngleField final
97  {
98  public:
99  #ifndef DOXYGEN_OMIT_INTERNAL
101  #endif // DOXYGEN_OMIT_INTERNAL
102  explicit operator bool() const;
116  bool has() const;
122  double get() const;
134  void get(int64_t* revolutions, float* radian_offset) const;
135 
136  private:
139 
141  };
142 
144  class BoolField final
145  {
146  public:
147  #ifndef DOXYGEN_OMIT_INTERNAL
148  BoolField(HebiInfoPtr internal, HebiInfoBoolField field);
149  #endif // DOXYGEN_OMIT_INTERNAL
150  bool has() const;
154  bool get() const;
155 
156  private:
159 
161  };
162 
164  class StringField final
165  {
166  public:
167  #ifndef DOXYGEN_OMIT_INTERNAL
169  #endif // DOXYGEN_OMIT_INTERNAL
170  explicit operator bool() const;
184  bool has() const;
187  std::string get() const;
188 
189  private:
192 
194  };
195 
197  class FlagField final
198  {
199  public:
200  #ifndef DOXYGEN_OMIT_INTERNAL
201  FlagField(HebiInfoPtr internal, HebiInfoFlagField field);
202  #endif // DOXYGEN_OMIT_INTERNAL
203  explicit operator bool() const;
217  bool has() const;
218 
219  private:
222 
224  };
225 
227  template <typename T>
228  class EnumField final
229  {
230  public:
231  #ifndef DOXYGEN_OMIT_INTERNAL
233  : internal_(internal), field_(field) {}
234  #endif // DOXYGEN_OMIT_INTERNAL
235  explicit operator bool() const { return has(); }
249  bool has() const { return (hebiInfoGetEnum(internal_, field_, nullptr) == HebiStatusSuccess); }
252  T get() const { int32_t ret{}; hebiInfoGetEnum(internal_, field_, &ret); return static_cast<T>(ret); }
253 
254  private:
257 
259  };
260 
262  class LedField final
263  {
264  public:
265  #ifndef DOXYGEN_OMIT_INTERNAL
266  LedField(HebiInfoPtr internal, HebiInfoLedField field);
267  #endif // DOXYGEN_OMIT_INTERNAL
268  explicit operator bool() const { return hasColor(); }
282  bool hasColor() const;
284  Color getColor() const;
285 
286  private:
289 
291  };
292 
294 
296  class Settings final
297  {
298  // Note: this is 'protected' instead of 'private' for easier use with Doxygen
299  protected:
301  class Actuator final
302  {
303  public:
304  #ifndef DOXYGEN_OMIT_INTERNAL
306  : internal_(internal),
310  spring_constant_(internal, HebiInfoFloatSpringConstant),
311  position_limit_min_(internal, HebiInfoHighResAnglePositionLimitMin),
312  position_limit_max_(internal, HebiInfoHighResAnglePositionLimitMax),
313  control_strategy_(internal, HebiInfoEnumControlStrategy)
314  {
315  }
316  #endif // DOXYGEN_OMIT_INTERNAL
317 
318  // With all submessage and field getters: Note that the returned reference
319  // should not be used after the lifetime of this parent.
320 
321  // Submessages ----------------
322 
324  const InfoGains& positionGains() const { return position_gains_; }
326  const InfoGains& velocityGains() const { return velocity_gains_; }
328  const InfoGains& effortGains() const { return effort_gains_; }
329 
330  // Subfields ----------------
331 
333  const FloatField& springConstant() const { return spring_constant_; }
335  const HighResAngleField& positionLimitMin() const { return position_limit_min_; }
337  const HighResAngleField& positionLimitMax() const { return position_limit_max_; }
339  const EnumField<ControlStrategy>& controlStrategy() const { return control_strategy_; }
340 
341  private:
343 
347 
352 
354  };
355 
356  public:
357  #ifndef DOXYGEN_OMIT_INTERNAL
359  : internal_(internal),
362  family_(internal, HebiInfoStringFamily),
363  save_current_settings_(internal, HebiInfoFlagSaveCurrentSettings)
364  {
365  }
366  #endif // DOXYGEN_OMIT_INTERNAL
367 
368  // With all submessage and field getters: Note that the returned reference
369  // should not be used after the lifetime of this parent.
370 
371  // Submessages ----------------
372 
374  const Actuator& actuator() const { return actuator_; }
375 
376  // Subfields ----------------
377 
379  const StringField& name() const { return name_; }
381  const StringField& family() const { return family_; }
383  const FlagField& saveCurrentSettings() const { return save_current_settings_; }
384 
385  private:
387 
389 
393 
395  };
396 
398  class Actuator final
399  {
400  public:
401  #ifndef DOXYGEN_OMIT_INTERNAL
403  : internal_(internal),
404  calibration_state_(internal, HebiInfoEnumCalibrationState)
405  {
406  }
407  #endif // DOXYGEN_OMIT_INTERNAL
408 
409  // With all submessage and field getters: Note that the returned reference
410  // should not be used after the lifetime of this parent.
411 
412  // Subfields ----------------
413 
415  const EnumField<CalibrationState>& calibrationState() const { return calibration_state_; }
416 
417  private:
419 
421 
423  };
424 
425  private:
431 
432  public:
433  #ifndef DOXYGEN_OMIT_INTERNAL
434 
438  Info(HebiInfoPtr );
439  #endif // DOXYGEN_OMIT_INTERNAL
440 
443  Info(Info&& other);
447  ~Info() noexcept; /* annotating specified destructor as noexcept is best-practice */
448 
449  // With all submessage and field getters: Note that the returned reference
450  // should not be used after the lifetime of this parent.
451 
452  // Submessages -------------------------------------------------------------
453 
455  const Settings& settings() const { return settings_; }
457  const Actuator& actuator() const { return actuator_; }
458 
459  // Subfields -------------------------------------------------------------
460 
462  const LedField& led() const;
463 
465  const StringField& serial() const { return serial_; }
466 
467  private:
470 
472 
474 
479 
480  /* Disable move assigment operator. */
481  Info& operator= (const Info&& other) = delete;
482 };
483 
484 } // namespace hebi
const FlagField & saveCurrentSettings() const
Indicates if the module should save the current values of all of its settings.
Definition: info.hpp:383
Module settings that are typically changed at a slower rate.
Definition: info.hpp:296
HebiInfoPtr const internal_
Definition: info.hpp:86
A message field for an angle measurement which does not lose precision at very high angles...
Definition: info.hpp:96
#define HEBI_DISABLE_COPY(Class)
Definition: util.hpp:17
HebiInfoPtr const internal_
Definition: info.hpp:418
Actuator-specific settings, such as controller gains.
Definition: info.hpp:301
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: hebi.h:239
HebiInfoPtr const internal_
Definition: info.hpp:255
HighResAngleField position_limit_min_
Definition: info.hpp:349
StringField serial_
Definition: info.hpp:473
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: hebi.h:226
A message field representable by a bool value.
Definition: info.hpp:144
Definition: color.hpp:5
const Settings & settings() const
Module settings that are typically changed at a slower rate.
Definition: info.hpp:455
HebiInfoEnumField const field_
Definition: info.hpp:256
const StringField & name() const
Gets the name for this module.
Definition: info.hpp:379
Actuator-specific information.
Definition: info.hpp:398
~Info() noexcept
Cleans up info object as necessary.
Definition: info.cpp:163
const Actuator & actuator() const
Actuator-specific information.
Definition: info.hpp:457
const Actuator & actuator() const
Actuator-specific settings, such as controller gains.
Definition: info.hpp:374
Info objects have various fields representing the module state; which fields are populated depends on...
Definition: info.hpp:30
EnumField< CalibrationState > calibration_state_
Definition: info.hpp:420
The firmware safety limit for the minimum allowed position.
Definition: hebi.h:244
CalibrationState
Definition: info.hpp:46
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:7
HebiInfoFloatField const field_
Definition: info.hpp:87
Actuator actuator_
Definition: info.hpp:388
A two-state message field (either set/true or cleared/false).
Definition: info.hpp:197
Actuator(HebiInfoPtr internal)
Definition: info.hpp:305
const FloatField & springConstant() const
The spring constant of the module.
Definition: info.hpp:333
HebiInfoFlagField const field_
Definition: info.hpp:221
HighResAngleField position_limit_max_
Definition: info.hpp:350
A message field for interfacing with an LED.
Definition: info.hpp:262
HebiInfoStringField
Definition: hebi.h:253
const InfoGains & effortGains() const
Controller gains for the effort PID loop.
Definition: info.hpp:328
EnumField< ControlStrategy > control_strategy_
Definition: info.hpp:351
FlagField save_current_settings_
Definition: info.hpp:392
HebiInfoHighResAngleField
Definition: hebi.h:242
HebiInfoPtr const internal_
Definition: info.hpp:342
Settings settings_
Definition: info.hpp:468
A combination of the position, velocity, and effort loops with P and V feeding to T; documented on do...
HebiInfoFlagField
Definition: hebi.h:259
const LedField & led() const
The module&#39;s LED.
Definition: info.cpp:178
const InfoGains & velocityGains() const
Controller gains for the velocity PID loop.
Definition: info.hpp:326
A direct PWM value (-1 to 1) can be sent to the motor (subject to onboard safety limiting).
const EnumField< CalibrationState > & calibrationState() const
The calibration state of the module.
Definition: info.hpp:415
HebiInfoBoolField
Definition: hebi.h:247
bool has() const
True if (and only if) the field has a value.
Definition: info.hpp:249
HebiInfoLedField
Definition: hebi.h:268
HebiInfoPtr const internal_
Definition: info.hpp:220
const StringField & family() const
Gets the family for this module.
Definition: info.hpp:381
HebiInfoPtr const internal_
Definition: info.hpp:190
The motor is not given power (equivalent to a 0 PWM value)
How the position, velocity, and effort PID loops are connected in order to control motor PWM...
Definition: hebi.h:265
HebiInfoPtr const internal_
Definition: info.hpp:386
ControlStrategy
Definition: info.hpp:33
A message field representable by a std::string.
Definition: info.hpp:164
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: hebi.h:250
HebiInfoFloatField
Definition: hebi.h:199
ROSCPP_DECL bool has(const std::string &key)
const EnumField< ControlStrategy > & controlStrategy() const
How the position, velocity, and effort PID loops are connected in order to control motor PWM...
Definition: info.hpp:339
Settings(HebiInfoPtr internal)
Definition: info.hpp:358
const HighResAngleField & positionLimitMax() const
The firmware safety limit for the maximum allowed position.
Definition: info.hpp:337
HebiInfoPtr const internal_
Definition: info.hpp:137
Info(HebiInfoPtr)
Wraps an existing C-style object that is managed by its parent. NOTE: this should not be used except ...
Definition: info.cpp:155
HebiInfoEnumField
Definition: hebi.h:263
A combination of the position, velocity, and effort loops with P feeding to T and V feeding to PWM; d...
HebiInfoPtr internal_
Definition: info.hpp:430
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: hebi.h:249
const StringField & serial() const
Gets the serial number for this module (e.g., X5-0001).
Definition: info.hpp:465
HebiInfoLedField const field_
Definition: info.hpp:288
HebiInfoStringField const field_
Definition: info.hpp:191
A combination of the position, velocity, and effort loops with P, V, and T feeding to PWM; documented...
EnumField(HebiInfoPtr internal, HebiInfoEnumField field)
Definition: info.hpp:232
const HighResAngleField & positionLimitMin() const
The firmware safety limit for the minimum allowed position.
Definition: info.hpp:335
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: hebi.h:213
LedField led_
Definition: info.hpp:471
Actuator actuator_
Definition: info.hpp:469
Actuator(HebiInfoPtr internal)
Definition: info.hpp:402
struct _HebiInfo * HebiInfoPtr
The C-style&#39;s API representation of a group.
Definition: hebi.h:362
StringField name_
Definition: info.hpp:390
HebiStatusCode hebiInfoGetEnum(HebiInfoPtr info, HebiInfoEnumField field, int32_t *value)
A message field representable by an enum of a given type.
Definition: info.hpp:228
Structure to describe an RGB color.
Definition: color.hpp:8
Gets the name for this module.
Definition: hebi.h:255
A message field representable by a single-precision floating point value.
Definition: info.hpp:60
HebiInfoHighResAngleField const field_
Definition: info.hpp:138
HebiInfoPtr const internal_
Definition: info.hpp:157
HebiInfoPtr const internal_
Definition: info.hpp:287
StringField family_
Definition: info.hpp:391
const InfoGains & positionGains() const
Controller gains for the position PID loop.
Definition: info.hpp:324
HebiInfoBoolField const field_
Definition: info.hpp:158


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