HEBI C++ API  3.15.0
command.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "hebi.h"
4 
5 #include <string>
6 
7 #include "color.hpp"
8 #include "gains.hpp"
9 #include "ip_address.hpp"
10 #include "message_helpers.hpp"
11 #include "util.hpp"
12 #include "vector_3_f.hpp"
13 
14 namespace hebi {
15 
35 class Command final {
36 public:
37  enum class ControlStrategy {
39  Off,
41  DirectPWM,
44  Strategy2,
47  Strategy3,
50  Strategy4,
53  Strategy5
54  };
55 
56  enum class MstopStrategy {
58  Disabled,
60  MotorOff,
63  };
64 
65  enum class PositionLimitStrategy {
71  MotorOff,
73  Disabled,
74  };
75 
76 protected:
78  class FloatField final {
79  public:
80 #ifndef DOXYGEN_OMIT_INTERNAL
81  FloatField(HebiCommandRef& internal, HebiCommandFloatField field);
82 #endif // DOXYGEN_OMIT_INTERNAL
83  explicit operator bool() const { return has(); }
97  bool has() const;
100  float get() const;
102  void set(float value);
104  void clear();
105 
107  private:
108  HebiCommandRef& internal_;
109  HebiCommandFloatField const field_;
110  };
111 
117  class HighResAngleField final {
118  public:
119 #ifndef DOXYGEN_OMIT_INTERNAL
120  HighResAngleField(HebiCommandRef& internal, HebiCommandHighResAngleField field);
121 #endif // DOXYGEN_OMIT_INTERNAL
122  explicit operator bool() const { return has(); }
136  bool has() const;
142  double get() const;
154  void get(int64_t* revolutions, float* radian_offset) const;
159  void set(double radians);
166  void set(int64_t revolutions, float radian_offset);
168  void clear();
169 
171  private:
172  HebiCommandRef& internal_;
173  HebiCommandHighResAngleField const field_;
174  };
175 
178  class NumberedFloatField final {
179  public:
180 #ifndef DOXYGEN_OMIT_INTERNAL
181  NumberedFloatField(HebiCommandRef& internal, HebiCommandNumberedFloatField field);
182 #endif // DOXYGEN_OMIT_INTERNAL
183  bool has(size_t fieldNumber) const;
194  float get(size_t fieldNumber) const;
200  void set(size_t fieldNumber, float value);
206  void clear(size_t fieldNumber);
207 
209  private:
210  HebiCommandRef& internal_;
211  HebiCommandNumberedFloatField const field_;
212  };
213 
215  class IpAddressField final {
216  public:
217 #ifndef DOXYGEN_OMIT_INTERNAL
218  IpAddressField(HebiCommandRef& internal, HebiCommandUInt64Field field);
219 #endif // DOXYGEN_OMIT_INTERNAL
220  explicit operator bool() const { return has(); }
234  bool has() const;
237  IpAddress get() const;
239  void set(const IpAddress& value);
241  void clear();
242 
244  private:
245  HebiCommandRef& internal_;
246  HebiCommandUInt64Field const field_;
247  };
248 
250  class BoolField final {
251  public:
252 #ifndef DOXYGEN_OMIT_INTERNAL
253  BoolField(HebiCommandRef& internal, HebiCommandBoolField field);
254 #endif // DOXYGEN_OMIT_INTERNAL
255  bool has() const;
259  bool get() const;
261  void set(bool value);
263  void clear();
264 
266  private:
267  HebiCommandRef& internal_;
268  HebiCommandBoolField const field_;
269  };
270 
272  class StringField final {
273  public:
274 #ifndef DOXYGEN_OMIT_INTERNAL
275  StringField(HebiCommandPtr internal, HebiCommandStringField field);
276 #endif // DOXYGEN_OMIT_INTERNAL
277  explicit operator bool() const { return has(); }
291  bool has() const;
294  std::string get() const;
296  void set(const std::string& value);
298  void clear();
299 
301  private:
302  HebiCommandPtr const internal_;
303  HebiCommandStringField const field_;
304  };
305 
307  class FlagField final {
308  public:
309 #ifndef DOXYGEN_OMIT_INTERNAL
310  FlagField(HebiCommandRef& internal, HebiCommandFlagField field);
311 #endif // DOXYGEN_OMIT_INTERNAL
312  explicit operator bool() const { return has(); }
326  bool has() const;
328  void set();
330  void clear();
331 
333  private:
334  HebiCommandRef& internal_;
335  HebiCommandFlagField const field_;
336  };
337 
338 
341  class Vector3fField final {
342  public:
343 #ifndef DOXYGEN_OMIT_INTERNAL
344  Vector3fField(HebiCommandRef& internal, HebiCommandVector3fField field);
345 #endif // DOXYGEN_OMIT_INTERNAL
346  explicit operator bool() const { return has(); }
360  bool has() const;
363  Vector3f get() const;
365  void set(const Vector3f& value);
367  void clear();
368 
370  private:
371  HebiCommandRef& internal_;
372  HebiCommandVector3fField const field_;
373  };
374 
376  template<typename T>
377  class EnumField final {
378  public:
379 #ifndef DOXYGEN_OMIT_INTERNAL
380  EnumField(HebiCommandRef& internal, HebiCommandEnumField field) : internal_(internal), field_(field) {}
381 #endif // DOXYGEN_OMIT_INTERNAL
382  explicit operator bool() const { return has(); }
396  bool has() const {
397  return enumGetter(internal_, field_, nullptr) == HebiStatusSuccess;
398  }
401  T get() const {
402  int32_t ret{};
403  enumGetter(internal_, field_, &ret);
404  return static_cast<T>(ret);
405  }
407  void set(T _value) {
408  int32_t value = static_cast<int32_t>(_value);
409  hebiCommandSetEnum(internal_, field_, &value);
410  }
412  void clear() {
413  hebiCommandSetEnum(internal_, field_, nullptr);
414  }
415 
417  private:
418  HebiCommandRef& internal_;
419  HebiCommandEnumField const field_;
420  };
421 
423  class IoBank final {
424  public:
425 #ifndef DOXYGEN_OMIT_INTERNAL
426  IoBank(HebiCommandPtr internal, HebiCommandRef& internal_ref, HebiCommandIoPinBank bank);
427 #endif // DOXYGEN_OMIT_INTERNAL
428  bool hasInt(size_t pinNumber) const;
439  bool hasFloat(size_t pinNumber) const;
445  int64_t getInt(size_t pinNumber) const;
452  float getFloat(size_t pinNumber) const;
458  void setInt(size_t pinNumber, int64_t value);
464  void setFloat(size_t pinNumber, float value);
470  bool hasLabel(size_t pinNumber) const;
476  std::string getLabel(size_t pinNumber) const;
481  void setLabel(size_t pinNumber, const std::string&);
486  void clear(size_t pinNumber);
487 
489  private:
490  HebiCommandPtr internal_;
491  HebiCommandRef& internal_ref_;
492  HebiCommandIoPinBank const bank_;
493  };
495  class LedField final {
496  public:
497 #ifndef DOXYGEN_OMIT_INTERNAL
498  LedField(HebiCommandRef& internal, HebiCommandLedField field);
499 #endif // DOXYGEN_OMIT_INTERNAL
500  bool has() const;
515  Color get() const;
521  void set(const Color& color);
526  void clear();
527 
529  private:
530  HebiCommandRef& internal_;
531  HebiCommandLedField const field_;
532  };
533 
535  class Io final {
536  public:
537 #ifndef DOXYGEN_OMIT_INTERNAL
538  Io(HebiCommandPtr internal, HebiCommandRef& internal_ref)
539  : a_(internal, internal_ref, HebiCommandIoBankA),
540  b_(internal, internal_ref, HebiCommandIoBankB),
541  c_(internal, internal_ref, HebiCommandIoBankC),
542  d_(internal, internal_ref, HebiCommandIoBankD),
543  e_(internal, internal_ref, HebiCommandIoBankE),
544  f_(internal, internal_ref, HebiCommandIoBankF) {}
545 #endif // DOXYGEN_OMIT_INTERNAL
546 
547  // With all submessage and field getters: Note that the returned reference
548  // should not be used after the lifetime of this parent.
549 
550  // Subfields ----------------
551 
553  IoBank& a() { return a_; }
555  const IoBank& a() const { return a_; }
557  IoBank& b() { return b_; }
559  const IoBank& b() const { return b_; }
561  IoBank& c() { return c_; }
563  const IoBank& c() const { return c_; }
565  IoBank& d() { return d_; }
567  const IoBank& d() const { return d_; }
569  IoBank& e() { return e_; }
571  const IoBank& e() const { return e_; }
573  IoBank& f() { return f_; }
575  const IoBank& f() const { return f_; }
576 
578  private:
579  IoBank a_;
580  IoBank b_;
581  IoBank c_;
582  IoBank d_;
583  IoBank e_;
584  IoBank f_;
585  };
586 
588 
590  class Settings final {
591  protected:
593  class Actuator final {
594  public:
595 #ifndef DOXYGEN_OMIT_INTERNAL
596  Actuator(HebiCommandRef& internal)
597  : position_gains_(internal, HebiCommandFloatPositionKp, HebiCommandBoolPositionDOnError),
598  velocity_gains_(internal, HebiCommandFloatVelocityKp, HebiCommandBoolVelocityDOnError),
599  effort_gains_(internal, HebiCommandFloatEffortKp, HebiCommandBoolEffortDOnError),
600  spring_constant_(internal, HebiCommandFloatSpringConstant),
601  reference_position_(internal, HebiCommandFloatReferencePosition),
602  reference_effort_(internal, HebiCommandFloatReferenceEffort),
603  velocity_limit_min_(internal, HebiCommandFloatVelocityLimitMin),
604  velocity_limit_max_(internal, HebiCommandFloatVelocityLimitMax),
605  effort_limit_min_(internal, HebiCommandFloatEffortLimitMin),
606  effort_limit_max_(internal, HebiCommandFloatEffortLimitMax),
607  offset_reference_position_(internal, HebiCommandFloatOffsetReferencePosition),
608  position_limit_min_(internal, HebiCommandHighResAnglePositionLimitMin),
609  position_limit_max_(internal, HebiCommandHighResAnglePositionLimitMax),
610  control_strategy_(internal, HebiCommandEnumControlStrategy),
611  mstop_strategy_(internal, HebiCommandEnumMstopStrategy),
612  min_position_limit_strategy_(internal, HebiCommandEnumMinPositionLimitStrategy),
613  max_position_limit_strategy_(internal, HebiCommandEnumMaxPositionLimitStrategy) {}
614 #endif // DOXYGEN_OMIT_INTERNAL
615 
616  // With all submessage and field getters: Note that the returned reference
617  // should not be used after the lifetime of this parent.
618 
619  // Submessages ----------------
620 
622  CommandGains& positionGains() { return position_gains_; }
624  const CommandGains& positionGains() const { return position_gains_; }
626  CommandGains& velocityGains() { return velocity_gains_; }
628  const CommandGains& velocityGains() const { return velocity_gains_; }
630  CommandGains& effortGains() { return effort_gains_; }
632  const CommandGains& effortGains() const { return effort_gains_; }
633 
634  // Subfields ----------------
635 
637  FloatField& springConstant() { return spring_constant_; }
639  const FloatField& springConstant() const { return spring_constant_; }
642  FloatField& referencePosition() { return reference_position_; }
645  const FloatField& referencePosition() const { return reference_position_; }
647  FloatField& referenceEffort() { return reference_effort_; }
649  const FloatField& referenceEffort() const { return reference_effort_; }
651  FloatField& velocityLimitMin() { return velocity_limit_min_; }
653  const FloatField& velocityLimitMin() const { return velocity_limit_min_; }
655  FloatField& velocityLimitMax() { return velocity_limit_max_; }
657  const FloatField& velocityLimitMax() const { return velocity_limit_max_; }
659  FloatField& effortLimitMin() { return effort_limit_min_; }
661  const FloatField& effortLimitMin() const { return effort_limit_min_; }
663  FloatField& effortLimitMax() { return effort_limit_max_; }
665  const FloatField& effortLimitMax() const { return effort_limit_max_; }
668  FloatField& offsetReferencePosition() { return offset_reference_position_; }
671  const FloatField& offsetReferencePosition() const { return offset_reference_position_; }
673  HighResAngleField& positionLimitMin() { return position_limit_min_; }
675  const HighResAngleField& positionLimitMin() const { return position_limit_min_; }
677  HighResAngleField& positionLimitMax() { return position_limit_max_; }
679  const HighResAngleField& positionLimitMax() const { return position_limit_max_; }
681  EnumField<ControlStrategy>& controlStrategy() { return control_strategy_; }
683  const EnumField<ControlStrategy>& controlStrategy() const { return control_strategy_; }
685  EnumField<MstopStrategy>& mstopStrategy() { return mstop_strategy_; }
687  const EnumField<MstopStrategy>& mstopStrategy() const { return mstop_strategy_; }
689  EnumField<PositionLimitStrategy>& minPositionLimitStrategy() { return min_position_limit_strategy_; }
691  const EnumField<PositionLimitStrategy>& minPositionLimitStrategy() const { return min_position_limit_strategy_; }
693  EnumField<PositionLimitStrategy>& maxPositionLimitStrategy() { return max_position_limit_strategy_; }
695  const EnumField<PositionLimitStrategy>& maxPositionLimitStrategy() const { return max_position_limit_strategy_; }
696 
698  private:
699  CommandGains position_gains_;
700  CommandGains velocity_gains_;
701  CommandGains effort_gains_;
702 
703  FloatField spring_constant_;
704  FloatField reference_position_;
705  FloatField reference_effort_;
706  FloatField velocity_limit_min_;
707  FloatField velocity_limit_max_;
708  FloatField effort_limit_min_;
709  FloatField effort_limit_max_;
710  FloatField offset_reference_position_;
711  HighResAngleField position_limit_min_;
712  HighResAngleField position_limit_max_;
713  EnumField<ControlStrategy> control_strategy_;
714  EnumField<MstopStrategy> mstop_strategy_;
715  EnumField<PositionLimitStrategy> min_position_limit_strategy_;
716  EnumField<PositionLimitStrategy> max_position_limit_strategy_;
717  };
718 
720  class Imu final {
721  public:
722 #ifndef DOXYGEN_OMIT_INTERNAL
723  Imu(HebiCommandRef& internal)
724  : accel_includes_gravity_(internal, HebiCommandBoolAccelIncludesGravity) {}
725 #endif // DOXYGEN_OMIT_INTERNAL
726 
727  // With all submessage and field getters: Note that the returned reference
728  // should not be used after the lifetime of this parent.
729 
730  // Subfields ----------------
731 
733  BoolField& accelIncludesGravity() { return accel_includes_gravity_; }
735  const BoolField& accelIncludesGravity() const { return accel_includes_gravity_; }
736 
738  private:
739  BoolField accel_includes_gravity_;
740  };
741 
742  public:
743 #ifndef DOXYGEN_OMIT_INTERNAL
744  Settings(HebiCommandPtr internal_ptr, HebiCommandRef& internal)
745  : actuator_(internal),
746  imu_(internal),
747  name_(internal_ptr, HebiCommandStringName),
748  family_(internal_ptr, HebiCommandStringFamily),
749  user_settings_bytes_1_(internal_ptr, HebiCommandStringUserSettingsBytes1),
750  user_settings_bytes_2_(internal_ptr, HebiCommandStringUserSettingsBytes2),
751  user_settings_bytes_3_(internal_ptr, HebiCommandStringUserSettingsBytes3),
752  user_settings_bytes_4_(internal_ptr, HebiCommandStringUserSettingsBytes4),
753  user_settings_bytes_5_(internal_ptr, HebiCommandStringUserSettingsBytes5),
754  user_settings_bytes_6_(internal_ptr, HebiCommandStringUserSettingsBytes6),
755  user_settings_bytes_7_(internal_ptr, HebiCommandStringUserSettingsBytes7),
756  user_settings_bytes_8_(internal_ptr, HebiCommandStringUserSettingsBytes8),
757  user_settings_float_1_(internal, HebiCommandFloatUserSettingsFloat1),
758  user_settings_float_2_(internal, HebiCommandFloatUserSettingsFloat2),
759  user_settings_float_3_(internal, HebiCommandFloatUserSettingsFloat3),
760  user_settings_float_4_(internal, HebiCommandFloatUserSettingsFloat4),
761  user_settings_float_5_(internal, HebiCommandFloatUserSettingsFloat5),
762  user_settings_float_6_(internal, HebiCommandFloatUserSettingsFloat6),
763  user_settings_float_7_(internal, HebiCommandFloatUserSettingsFloat7),
764  user_settings_float_8_(internal, HebiCommandFloatUserSettingsFloat8),
765  ip_address_(internal, HebiCommandUInt64IpAddress),
766  subnet_mask_(internal, HebiCommandUInt64SubnetMask),
767  save_current_settings_(internal, HebiCommandFlagSaveCurrentSettings) {}
768 #endif // DOXYGEN_OMIT_INTERNAL
769 
770  // With all submessage and field getters: Note that the returned reference
771  // should not be used after the lifetime of this parent.
772 
773  // Submessages ----------------
774 
776  Actuator& actuator() { return actuator_; }
778  const Actuator& actuator() const { return actuator_; }
780  Imu& imu() { return imu_; }
782  const Imu& imu() const { return imu_; }
783 
784  // Subfields ----------------
785 
788  StringField& name() { return name_; }
791  const StringField& name() const { return name_; }
794  StringField& family() { return family_; }
797  const StringField& family() const { return family_; }
801  {
802  switch (number) {
803  case 1: return user_settings_bytes_1_;
804  case 2: return user_settings_bytes_2_;
805  case 3: return user_settings_bytes_3_;
806  case 4: return user_settings_bytes_4_;
807  case 5: return user_settings_bytes_5_;
808  case 6: return user_settings_bytes_6_;
809  case 7: return user_settings_bytes_7_;
810  case 8: return user_settings_bytes_8_;
811  }
812  throw std::out_of_range("Invalid option for bytes array user setting entry!");
813  }
816  const StringField& userSettingsBytes(size_t number) const
817  {
818  switch (number) {
819  case 1: return user_settings_bytes_1_;
820  case 2: return user_settings_bytes_2_;
821  case 3: return user_settings_bytes_3_;
822  case 4: return user_settings_bytes_4_;
823  case 5: return user_settings_bytes_5_;
824  case 6: return user_settings_bytes_6_;
825  case 7: return user_settings_bytes_7_;
826  case 8: return user_settings_bytes_8_;
827  }
828  throw std::out_of_range("Invalid option for bytes array user setting entry!");
829  }
833  {
834  switch (number) {
835  case 1: return user_settings_float_1_;
836  case 2: return user_settings_float_2_;
837  case 3: return user_settings_float_3_;
838  case 4: return user_settings_float_4_;
839  case 5: return user_settings_float_5_;
840  case 6: return user_settings_float_6_;
841  case 7: return user_settings_float_7_;
842  case 8: return user_settings_float_8_;
843  }
844  throw std::out_of_range("Invalid option for float user setting entry!");
845  }
848  const FloatField& userSettingsFloat(size_t number) const
849  {
850  switch (number) {
851  case 1: return user_settings_float_1_;
852  case 2: return user_settings_float_2_;
853  case 3: return user_settings_float_3_;
854  case 4: return user_settings_float_4_;
855  case 5: return user_settings_float_5_;
856  case 6: return user_settings_float_6_;
857  case 7: return user_settings_float_7_;
858  case 8: return user_settings_float_8_;
859  }
860  throw std::out_of_range("Invalid option for float user setting entry!");
861  }
864  IpAddressField& ipAddress() { return ip_address_; }
867  const IpAddressField& ipAddress() const { return ip_address_; }
869  IpAddressField& subnetMask() { return subnet_mask_; }
871  const IpAddressField& subnetMask() const { return subnet_mask_; }
873  FlagField& saveCurrentSettings() { return save_current_settings_; }
875  const FlagField& saveCurrentSettings() const { return save_current_settings_; }
876 
878 
879  private:
880  Actuator actuator_;
881  Imu imu_;
882 
883  StringField name_;
884  StringField family_;
885  StringField user_settings_bytes_1_;
886  StringField user_settings_bytes_2_;
887  StringField user_settings_bytes_3_;
888  StringField user_settings_bytes_4_;
889  StringField user_settings_bytes_5_;
890  StringField user_settings_bytes_6_;
891  StringField user_settings_bytes_7_;
892  StringField user_settings_bytes_8_;
893  FloatField user_settings_float_1_;
894  FloatField user_settings_float_2_;
895  FloatField user_settings_float_3_;
896  FloatField user_settings_float_4_;
897  FloatField user_settings_float_5_;
898  FloatField user_settings_float_6_;
899  FloatField user_settings_float_7_;
900  FloatField user_settings_float_8_;
901  IpAddressField ip_address_;
902  IpAddressField subnet_mask_;
903  FlagField save_current_settings_;
904  };
905 
907  class Actuator final {
908  public:
909 #ifndef DOXYGEN_OMIT_INTERNAL
910  Actuator(HebiCommandRef& internal)
911  : velocity_(internal, HebiCommandFloatVelocity),
912  effort_(internal, HebiCommandFloatEffort),
913  position_(internal, HebiCommandHighResAnglePosition) {}
914 #endif // DOXYGEN_OMIT_INTERNAL
915 
916  // With all submessage and field getters: Note that the returned reference
917  // should not be used after the lifetime of this parent.
918 
919  // Subfields ----------------
920 
922  FloatField& velocity() { return velocity_; }
924  const FloatField& velocity() const { return velocity_; }
926  FloatField& effort() { return effort_; }
928  const FloatField& effort() const { return effort_; }
930  HighResAngleField& position() { return position_; }
932  const HighResAngleField& position() const { return position_; }
933 
935  private:
936  FloatField velocity_;
937  FloatField effort_;
938  HighResAngleField position_;
939  };
940 
941 private:
946  HebiCommandPtr internal_;
947  HebiCommandRef internal_ref_;
948 
949 public:
950 #ifndef DOXYGEN_OMIT_INTERNAL
951 
955  Command(HebiCommandPtr);
956 #endif // DOXYGEN_OMIT_INTERNAL
957 
960  Command(Command&& other);
961 
962  // With all submessage and field getters: Note that the returned reference
963  // should not be used after the lifetime of this parent.
964 
965  // Submessages -------------------------------------------------------------
966 
968  Io& io() { return io_; }
970  const Io& io() const { return io_; }
972  Settings& settings() { return settings_; }
974  const Settings& settings() const { return settings_; }
976  Actuator& actuator() { return actuator_; }
978  const Actuator& actuator() const { return actuator_; }
979 
980  // Subfields -------------------------------------------------------------
981 
982 #ifndef DOXYGEN_OMIT_INTERNAL
983  NumberedFloatField& debug() { return debug_; }
986  const NumberedFloatField& debug() const { return debug_; }
987 #endif // DOXYGEN_OMIT_INTERNAL
988  StringField& appendLog() { return append_log_; }
991  const StringField& appendLog() const { return append_log_; }
993  FlagField& reset() { return reset_; }
995  const FlagField& reset() const { return reset_; }
997  FlagField& boot() { return boot_; }
999  const FlagField& boot() const { return boot_; }
1001  FlagField& stopBoot() { return stop_boot_; }
1003  const FlagField& stopBoot() const { return stop_boot_; }
1005  FlagField& clearLog() { return clear_log_; }
1007  const FlagField& clearLog() const { return clear_log_; }
1009  LedField& led() { return led_; }
1011  const LedField& led() const { return led_; }
1013  Vector3fField& force() { return force_; }
1015  const Vector3fField& force() const { return force_; }
1017  Vector3fField& torque() { return torque_; }
1019  const Vector3fField& torque() const { return torque_; }
1020 
1025 
1026  /* Disable move assigment operator. */
1027  Command& operator=(Command&& other) = delete;
1028 
1029 private:
1030  Io io_;
1031  Settings settings_;
1032  Actuator actuator_;
1033 
1034  NumberedFloatField debug_;
1035  StringField append_log_;
1036  FlagField reset_;
1037  FlagField boot_;
1038  FlagField stop_boot_;
1039  FlagField clear_log_;
1040  LedField led_;
1041  Vector3fField force_;
1042  Vector3fField torque_;
1043 };
1044 
1045 } // namespace hebi
const FloatField & referencePosition() const
Definition: command.hpp:645
void clear()
Removes any currently set value for this field.
Definition: command.cpp:130
void clear()
Removes any currently set value for this field.
Definition: command.cpp:193
void set(const Color &color)
Commands a color that overrides the module's control of the LED (if the alpha channel is 255),...
Definition: command.cpp:269
bool has() const
True if (and only if) the field has a value.
Definition: command.hpp:396
void clear()
Removes any currently set value for this field.
Definition: command.cpp:67
const IoBank & a() const
I/O pin bank a (pins 1-8 available)
Definition: command.hpp:555
IoBank & f()
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:573
IpAddress get() const
If the field has a value, returns that value; otherwise, returns 0.0.0.0.
Definition: command.cpp:99
FloatField & offsetReferencePosition()
Definition: command.hpp:668
FlagField & reset()
Restart the module.
Definition: command.hpp:993
FlagField & saveCurrentSettings()
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:873
IoBank & d()
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:565
const EnumField< PositionLimitStrategy > & minPositionLimitStrategy() const
The position limit strategy (at the minimum position) for the actuator.
Definition: command.hpp:691
MstopStrategy
Definition: command.hpp:56
const FloatField & effortLimitMin() const
The firmware safety limit for the minimum allowed effort.
Definition: command.hpp:661
Structure to hold a 3-D floating point vector (i.e., x/y/z components)
Definition: vector_3_f.hpp:8
void clear()
Removes any currently set value for this field.
Definition: command.cpp:112
const FloatField & velocityLimitMin() const
The firmware safety limit for the minimum allowed velocity.
Definition: command.hpp:653
HighResAngleField & positionLimitMax()
The firmware safety limit for the maximum allowed position.
Definition: command.hpp:677
#define HEBI_DISABLE_COPY(Class)
Definition: util.hpp:16
void clear()
Removes any currently set value for this field.
Definition: command.cpp:27
std::string getLabel(size_t pinNumber) const
If this numbered pin in this bank has a string label value, returns that value; otherwise returns an ...
Definition: command.cpp:229
A message field representable by a bool value.
Definition: command.hpp:250
Actuator & actuator()
Actuator-specific commands.
Definition: command.hpp:976
const FloatField & offsetReferencePosition() const
Definition: command.hpp:671
Actuator-specific commands.
Definition: command.hpp:907
void hebiCommandSetEnum(HebiCommandRef &command, HebiCommandEnumField field, const int32_t *value)
Definition: message_helpers.cpp:390
Io & io()
Any available digital or analog output pins on the device.
Definition: command.hpp:968
const FloatField & effort() const
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages).
Definition: command.hpp:928
Triggering the M-Stop results in the control strategy being set to 'off'. Remains 'off' until changed...
Settings & settings()
Module settings that are typically changed at a slower rate.
Definition: command.hpp:972
StringField & userSettingsBytes(size_t number)
Definition: command.hpp:800
const Io & io() const
Any available digital or analog output pins on the device.
Definition: command.hpp:970
FloatField & springConstant()
The spring constant of the module.
Definition: command.hpp:637
bool get() const
If the field has a value, returns that value; otherwise, returns false.
Definition: command.cpp:119
FloatField & effortLimitMin()
The firmware safety limit for the minimum allowed effort.
Definition: command.hpp:659
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:117
A message field for interfacing with a bank of I/O pins.
Definition: command.hpp:423
Triggering the M-Stop results in the motor holding the motor position. Operations resume to normal on...
FlagField & boot()
Boot the module from bootloader into application.
Definition: command.hpp:997
Actuator & actuator()
Actuator-specific settings, such as controller gains.
Definition: command.hpp:776
const HighResAngleField & position() const
Position of the module output (post-spring), in radians.
Definition: command.hpp:932
const IoBank & d() const
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:567
void setInt(size_t pinNumber, int64_t value)
Sets the particular pin to a integer value (representing a digital output).
Definition: command.cpp:217
StringField & family()
Definition: command.hpp:794
Command objects have various fields that can be set; when sent to the module, these fields control in...
Definition: command.hpp:35
const BoolField & accelIncludesGravity() const
Whether to include acceleration due to gravity in acceleration feedback.
Definition: command.hpp:735
IoBank & a()
I/O pin bank a (pins 1-8 available)
Definition: command.hpp:553
A message field representable by a std::string.
Definition: command.hpp:272
BoolField & accelIncludesGravity()
Whether to include acceleration due to gravity in acceleration feedback.
Definition: command.hpp:733
Definition: arm.cpp:10
FloatField & userSettingsFloat(size_t number)
Definition: command.hpp:832
A message field representable by a 3-D vector of single-precision floating point values.
Definition: command.hpp:341
bool hasLabel(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has a string label set in this message...
Definition: command.cpp:225
void clear(size_t fieldNumber)
Removes any currently set value for the numbered subvalue of this field.
Definition: command.cpp:88
void set(size_t fieldNumber, float value)
Sets the particular numbered subvalue of this field to a given value.
Definition: command.cpp:84
std::string get() const
If the field has a value, returns a copy of that value; otherwise, returns a default.
Definition: command.cpp:139
IpAddressField & subnetMask()
Sets the subnet mask for this module; must be used with IP Address if setting a static IP address.
Definition: command.hpp:869
void set()
Sets this flag.
Definition: command.cpp:164
A message field for interfacing with an LED.
Definition: command.hpp:495
const FlagField & clearLog() const
Clears the log message on the module.
Definition: command.hpp:1007
Exceeding the position limit results in the actuator holding the position. Needs to be manually set t...
const FloatField & effortLimitMax() const
The firmware safety limit for the maximum allowed effort.
Definition: command.hpp:665
The motor is not given power (equivalent to a 0 PWM value)
const IpAddressField & subnetMask() const
Sets the subnet mask for this module; must be used with IP Address if setting a static IP address.
Definition: command.hpp:871
const StringField & name() const
Definition: command.hpp:791
CommandGains & effortGains()
Controller gains for the effort PID loop.
Definition: command.hpp:630
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:6
const FlagField & reset() const
Restart the module.
Definition: command.hpp:995
const IoBank & c() const
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:563
IoBank & c()
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:561
const CommandGains & effortGains() const
Controller gains for the effort PID loop.
Definition: command.hpp:632
HighResAngleField & position()
Position of the module output (post-spring), in radians.
Definition: command.hpp:930
const FloatField & springConstant() const
The spring constant of the module.
Definition: command.hpp:639
Exceeding the position limit results in the control strategy being set to 'off'. Remains 'off' until ...
const EnumField< ControlStrategy > & controlStrategy() const
How the position, velocity, and effort PID loops are connected in order to control motor PWM.
Definition: command.hpp:683
CommandGains & velocityGains()
Controller gains for the velocity PID loop.
Definition: command.hpp:626
const IoBank & b() const
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:559
Actuator-specific settings, such as controller gains.
Definition: command.hpp:593
Module settings that are typically changed at a slower rate.
Definition: command.hpp:590
const CommandGains & positionGains() const
Controller gains for the position PID loop.
Definition: command.hpp:624
FloatField & referencePosition()
Definition: command.hpp:642
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:32
const Settings & settings() const
Module settings that are typically changed at a slower rate.
Definition: command.hpp:974
A two-state message field (either set/true or cleared/false).
Definition: command.hpp:307
void set(T _value)
Sets the field to a given value.
Definition: command.hpp:407
bool has() const
Returns true if the flag is set, false if it is cleared.
Definition: command.cpp:162
StringField & appendLog()
Appends to the current log message on the module.
Definition: command.hpp:989
const Actuator & actuator() const
Actuator-specific settings, such as controller gains.
Definition: command.hpp:778
IoBank & b()
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:557
const IoBank & e() const
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:571
A message field containing a numbered set of single-precision floating point values.
Definition: command.hpp:178
Triggering the M-Stop has no effect.
HebiStatusCode enumGetter(const RefT &ref, MetadataT &metadata, int field, int32_t *value)
Definition: message_helpers.cpp:300
const FloatField & userSettingsFloat(size_t number) const
Definition: command.hpp:848
const StringField & family() const
Definition: command.hpp:797
Color get() const
Returns the current LED command.
Definition: command.cpp:258
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: command.cpp:205
double get() const
If the field has a value, returns that value as a double; otherwise, returns a default.
Definition: command.cpp:36
const FlagField & boot() const
Boot the module from bootloader into application.
Definition: command.hpp:999
FloatField & effortLimitMax()
The firmware safety limit for the maximum allowed effort.
Definition: command.hpp:663
const Vector3fField & torque() const
Cartesian torque data, such as to a haptic device.
Definition: command.hpp:1019
EnumField< ControlStrategy > & controlStrategy()
How the position, velocity, and effort PID loops are connected in order to control motor PWM.
Definition: command.hpp:681
const LedField & led() const
The module's LED.
Definition: command.hpp:1011
HighResAngleField & positionLimitMin()
The firmware safety limit for the minimum allowed position.
Definition: command.hpp:673
float getFloat(size_t pinNumber) const
If this numbered pin in this bank has an floating point (e.g., analog or PWM) value,...
Definition: command.cpp:211
FloatField & velocity()
Velocity of the module output (post-spring), in radians/second.
Definition: command.hpp:922
Exceeding the position limit results in a virtual spring that pushes the actuator back to within the ...
const IpAddressField & ipAddress() const
Definition: command.hpp:867
Any available digital or analog output pins on the device.
Definition: command.hpp:535
const HighResAngleField & positionLimitMin() const
The firmware safety limit for the minimum allowed position.
Definition: command.hpp:675
float get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: command.cpp:17
FloatField & referenceEffort()
The internal effort reference offset (setting this matches the current effort to the given reference ...
Definition: command.hpp:647
ControlStrategy
Definition: command.hpp:37
const EnumField< PositionLimitStrategy > & maxPositionLimitStrategy() const
The position limit strategy (at the maximum position) for the actuator.
Definition: command.hpp:695
A simple wrapper class for IpAddress objects.
Definition: ip_address.hpp:36
const HighResAngleField & positionLimitMax() const
The firmware safety limit for the maximum allowed position.
Definition: command.hpp:679
const Imu & imu() const
IMU-specific settings.
Definition: command.hpp:782
const FloatField & referenceEffort() const
The internal effort reference offset (setting this matches the current effort to the given reference ...
Definition: command.hpp:649
const FlagField & saveCurrentSettings() const
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:875
void clear()
Removes any currently set value for this field.
Definition: command.hpp:412
IoBank & e()
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:569
FlagField & clearLog()
Clears the log message on the module.
Definition: command.hpp:1005
EnumField< PositionLimitStrategy > & maxPositionLimitStrategy()
The position limit strategy (at the maximum position) for the actuator.
Definition: command.hpp:693
void set(const Vector3f &value)
Sets the field to a given value.
Definition: command.cpp:185
const EnumField< MstopStrategy > & mstopStrategy() const
The motion stop strategy for the actuator.
Definition: command.hpp:687
T get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: command.hpp:401
void clear()
Removes any currently set value for this field, so that the module maintains its previous state of LE...
Definition: command.cpp:273
Command(Command &&other)
Move constructor (necessary for containment in STL template classes)
Definition: command.cpp:277
A message field for an angle measurement which does not lose precision at very high angles.
Definition: command.hpp:117
void set(double radians)
Sets the field to a given double value (in radians). Note that double precision floating point number...
Definition: command.cpp:52
Imu & imu()
IMU-specific settings.
Definition: command.hpp:780
const FlagField & stopBoot() const
Stop the module from automatically booting into application.
Definition: command.hpp:1003
void clear()
Removes any currently set value for this field.
Definition: command.cpp:157
EnumField< MstopStrategy > & mstopStrategy()
The motion stop strategy for the actuator.
Definition: command.hpp:685
void set(float value)
Sets the field to a given value.
Definition: command.cpp:25
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:171
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:135
void set(bool value)
Sets the field to a given value.
Definition: command.cpp:125
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:95
const FloatField & velocity() const
Velocity of the module output (post-spring), in radians/second.
Definition: command.hpp:924
const Actuator & actuator() const
Actuator-specific commands.
Definition: command.hpp:978
Vector3fField & torque()
Cartesian torque data, such as to a haptic device.
Definition: command.hpp:1017
float get(size_t fieldNumber) const
If the particular numbered subvalue of this field has a value, returns that value; otherwise returns ...
Definition: command.cpp:76
FloatField & velocityLimitMax()
The firmware safety limit for the maximum allowed velocity.
Definition: command.hpp:655
const StringField & appendLog() const
Appends to the current log message on the module.
Definition: command.hpp:991
const FloatField & velocityLimitMax() const
The firmware safety limit for the maximum allowed velocity.
Definition: command.hpp:657
IMU-specific settings.
Definition: command.hpp:720
Vector3fField & force()
Cartesian force data, such as to a haptic device.
Definition: command.hpp:1013
StringField & name()
Definition: command.hpp:788
LedField & led()
The module's LED.
Definition: command.hpp:1009
void setFloat(size_t pinNumber, float value)
Sets the particular pin to a floating point value (representing a PWM output).
Definition: command.cpp:221
void setLabel(size_t pinNumber, const std::string &)
Sets the string label for a particular pin.
Definition: command.cpp:241
Exceeding the position limit has no effect.
bool has() const
Returns true if the LED command has been set, and false otherwise.
Definition: command.cpp:254
void set(const IpAddress &value)
Sets the field to a given value.
Definition: command.cpp:107
bool hasFloat(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an floating point (e....
Definition: command.cpp:201
const CommandGains & velocityGains() const
Controller gains for the velocity PID loop.
Definition: command.hpp:628
bool hasInt(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an integer (e.g....
Definition: command.cpp:197
const IoBank & f() const
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:575
A direct PWM value (-1 to 1) can be sent to the motor (subject to onboard safety limiting).
Vector3f get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: command.cpp:175
Structure to describe an RGB color.
Definition: color.hpp:8
const Vector3fField & force() const
Cartesian force data, such as to a haptic device.
Definition: command.hpp:1015
CommandGains & positionGains()
Controller gains for the position PID loop.
Definition: command.hpp:622
A message field representable by an unsigned 64 bit integer value.
Definition: command.hpp:215
A message field representable by a single-precision floating point value.
Definition: command.hpp:78
bool has(size_t fieldNumber) const
True if (and only if) the particular numbered subvalue of this field has a value.
Definition: command.cpp:72
void clear()
Clears this flag (e.g., sets it to false/off).
Definition: command.cpp:166
Command & operator=(Command &&other)=delete
PositionLimitStrategy
Definition: command.hpp:65
const StringField & userSettingsBytes(size_t number) const
Definition: command.hpp:816
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:15
FloatField & velocityLimitMin()
The firmware safety limit for the minimum allowed velocity.
Definition: command.hpp:651
void clear(size_t pinNumber)
Removes any currently set value for this pin.
Definition: command.cpp:247
void set(const std::string &value)
Sets the field to a given value.
Definition: command.cpp:151
IpAddressField & ipAddress()
Definition: command.hpp:864
EnumField< PositionLimitStrategy > & minPositionLimitStrategy()
The position limit strategy (at the minimum position) for the actuator.
Definition: command.hpp:689
FlagField & stopBoot()
Stop the module from automatically booting into application.
Definition: command.hpp:1001
A message field representable by an enum of a given type.
Definition: command.hpp:377
FloatField & effort()
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages).
Definition: command.hpp:926