HEBI C++ API  3.8.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 
13 namespace hebi {
14 
34 class Command final {
35 public:
36  enum class ControlStrategy {
38  Off,
40  DirectPWM,
43  Strategy2,
46  Strategy3,
49  Strategy4,
50  };
51 
52  enum class MstopStrategy {
54  Disabled,
56  MotorOff,
59  };
60 
61  enum class PositionLimitStrategy {
67  MotorOff,
69  Disabled,
70  };
71 
72 protected:
74  class FloatField final {
75  public:
76 #ifndef DOXYGEN_OMIT_INTERNAL
77  FloatField(HebiCommandRef& internal, HebiCommandFloatField field);
78 #endif // DOXYGEN_OMIT_INTERNAL
79  explicit operator bool() const { return has(); }
93  bool has() const;
96  float get() const;
98  void set(float value);
100  void clear();
101 
103  private:
104  HebiCommandRef& internal_;
105  HebiCommandFloatField const field_;
106  };
107 
113  class HighResAngleField final {
114  public:
115 #ifndef DOXYGEN_OMIT_INTERNAL
116  HighResAngleField(HebiCommandRef& internal, HebiCommandHighResAngleField field);
117 #endif // DOXYGEN_OMIT_INTERNAL
118  explicit operator bool() const { return has(); }
132  bool has() const;
138  double get() const;
150  void get(int64_t* revolutions, float* radian_offset) const;
155  void set(double radians);
162  void set(int64_t revolutions, float radian_offset);
164  void clear();
165 
167  private:
168  HebiCommandRef& internal_;
169  HebiCommandHighResAngleField const field_;
170  };
171 
174  class NumberedFloatField final {
175  public:
176 #ifndef DOXYGEN_OMIT_INTERNAL
177  NumberedFloatField(HebiCommandRef& internal, HebiCommandNumberedFloatField field);
178 #endif // DOXYGEN_OMIT_INTERNAL
179  bool has(size_t fieldNumber) const;
190  float get(size_t fieldNumber) const;
196  void set(size_t fieldNumber, float value);
202  void clear(size_t fieldNumber);
203 
205  private:
206  HebiCommandRef& internal_;
207  HebiCommandNumberedFloatField const field_;
208  };
209 
211  class IpAddressField final {
212  public:
213 #ifndef DOXYGEN_OMIT_INTERNAL
214  IpAddressField(HebiCommandRef& internal, HebiCommandUInt64Field field);
215 #endif // DOXYGEN_OMIT_INTERNAL
216  explicit operator bool() const { return has(); }
230  bool has() const;
233  IpAddress get() const;
235  void set(const IpAddress& value);
237  void clear();
238 
240  private:
241  HebiCommandRef& internal_;
242  HebiCommandUInt64Field const field_;
243  };
244 
246  class BoolField final {
247  public:
248 #ifndef DOXYGEN_OMIT_INTERNAL
249  BoolField(HebiCommandRef& internal, HebiCommandBoolField field);
250 #endif // DOXYGEN_OMIT_INTERNAL
251  bool has() const;
255  bool get() const;
257  void set(bool value);
259  void clear();
260 
262  private:
263  HebiCommandRef& internal_;
264  HebiCommandBoolField const field_;
265  };
266 
268  class StringField final {
269  public:
270 #ifndef DOXYGEN_OMIT_INTERNAL
271  StringField(HebiCommandPtr internal, HebiCommandStringField field);
272 #endif // DOXYGEN_OMIT_INTERNAL
273  explicit operator bool() const { return has(); }
287  bool has() const;
290  std::string get() const;
292  void set(const std::string& value);
294  void clear();
295 
297  private:
298  HebiCommandPtr const internal_;
299  HebiCommandStringField const field_;
300  };
301 
303  class FlagField final {
304  public:
305 #ifndef DOXYGEN_OMIT_INTERNAL
306  FlagField(HebiCommandRef& internal, HebiCommandFlagField field);
307 #endif // DOXYGEN_OMIT_INTERNAL
308  explicit operator bool() const { return has(); }
322  bool has() const;
324  void set();
326  void clear();
327 
329  private:
330  HebiCommandRef& internal_;
331  HebiCommandFlagField const field_;
332  };
333 
335  template<typename T>
336  class EnumField final {
337  public:
338 #ifndef DOXYGEN_OMIT_INTERNAL
339  EnumField(HebiCommandRef& internal, HebiCommandEnumField field) : internal_(internal), field_(field) {}
340 #endif // DOXYGEN_OMIT_INTERNAL
341  explicit operator bool() const { return has(); }
355  bool has() const {
356  return enumGetter(internal_, field_, nullptr) == HebiStatusSuccess;
357  }
360  T get() const {
361  int32_t ret{};
362  enumGetter(internal_, field_, &ret);
363  return static_cast<T>(ret);
364  }
366  void set(T _value) {
367  int32_t value = static_cast<int32_t>(_value);
368  hebiCommandSetEnum(internal_, field_, &value);
369  }
371  void clear() {
372  hebiCommandSetEnum(internal_, field_, nullptr);
373  }
374 
376  private:
377  HebiCommandRef& internal_;
378  HebiCommandEnumField const field_;
379  };
380 
382  class IoBank final {
383  public:
384 #ifndef DOXYGEN_OMIT_INTERNAL
385  IoBank(HebiCommandPtr internal, HebiCommandRef& internal_ref, HebiCommandIoPinBank bank);
386 #endif // DOXYGEN_OMIT_INTERNAL
387  bool hasInt(size_t pinNumber) const;
398  bool hasFloat(size_t pinNumber) const;
404  int64_t getInt(size_t pinNumber) const;
411  float getFloat(size_t pinNumber) const;
417  void setInt(size_t pinNumber, int64_t value);
423  void setFloat(size_t pinNumber, float value);
429  bool hasLabel(size_t pinNumber) const;
435  std::string getLabel(size_t pinNumber) const;
440  void setLabel(size_t pinNumber, const std::string&);
445  void clear(size_t pinNumber);
446 
448  private:
449  HebiCommandPtr internal_;
450  HebiCommandRef& internal_ref_;
451  HebiCommandIoPinBank const bank_;
452  };
454  class LedField final {
455  public:
456 #ifndef DOXYGEN_OMIT_INTERNAL
457  LedField(HebiCommandRef& internal, HebiCommandLedField field);
458 #endif // DOXYGEN_OMIT_INTERNAL
459  bool has() const;
474  Color get() const;
480  void set(const Color& color);
485  void clear();
486 
488  private:
489  HebiCommandRef& internal_;
490  HebiCommandLedField const field_;
491  };
492 
494  class Io final {
495  public:
496 #ifndef DOXYGEN_OMIT_INTERNAL
497  Io(HebiCommandPtr internal, HebiCommandRef& internal_ref)
498  : a_(internal, internal_ref, HebiCommandIoBankA),
499  b_(internal, internal_ref, HebiCommandIoBankB),
500  c_(internal, internal_ref, HebiCommandIoBankC),
501  d_(internal, internal_ref, HebiCommandIoBankD),
502  e_(internal, internal_ref, HebiCommandIoBankE),
503  f_(internal, internal_ref, HebiCommandIoBankF) {}
504 #endif // DOXYGEN_OMIT_INTERNAL
505 
506  // With all submessage and field getters: Note that the returned reference
507  // should not be used after the lifetime of this parent.
508 
509  // Subfields ----------------
510 
512  IoBank& a() { return a_; }
514  const IoBank& a() const { return a_; }
516  IoBank& b() { return b_; }
518  const IoBank& b() const { return b_; }
520  IoBank& c() { return c_; }
522  const IoBank& c() const { return c_; }
524  IoBank& d() { return d_; }
526  const IoBank& d() const { return d_; }
528  IoBank& e() { return e_; }
530  const IoBank& e() const { return e_; }
532  IoBank& f() { return f_; }
534  const IoBank& f() const { return f_; }
535 
537  private:
538  IoBank a_;
539  IoBank b_;
540  IoBank c_;
541  IoBank d_;
542  IoBank e_;
543  IoBank f_;
544  };
545 
547 
549  class Settings final {
550  protected:
552  class Actuator final {
553  public:
554 #ifndef DOXYGEN_OMIT_INTERNAL
555  Actuator(HebiCommandRef& internal)
556  : position_gains_(internal, HebiCommandFloatPositionKp, HebiCommandBoolPositionDOnError),
557  velocity_gains_(internal, HebiCommandFloatVelocityKp, HebiCommandBoolVelocityDOnError),
558  effort_gains_(internal, HebiCommandFloatEffortKp, HebiCommandBoolEffortDOnError),
559  spring_constant_(internal, HebiCommandFloatSpringConstant),
560  reference_position_(internal, HebiCommandFloatReferencePosition),
561  reference_effort_(internal, HebiCommandFloatReferenceEffort),
562  velocity_limit_min_(internal, HebiCommandFloatVelocityLimitMin),
563  velocity_limit_max_(internal, HebiCommandFloatVelocityLimitMax),
564  effort_limit_min_(internal, HebiCommandFloatEffortLimitMin),
565  effort_limit_max_(internal, HebiCommandFloatEffortLimitMax),
566  position_limit_min_(internal, HebiCommandHighResAnglePositionLimitMin),
567  position_limit_max_(internal, HebiCommandHighResAnglePositionLimitMax),
568  control_strategy_(internal, HebiCommandEnumControlStrategy),
569  mstop_strategy_(internal, HebiCommandEnumMstopStrategy),
570  min_position_limit_strategy_(internal, HebiCommandEnumMinPositionLimitStrategy),
571  max_position_limit_strategy_(internal, HebiCommandEnumMaxPositionLimitStrategy) {}
572 #endif // DOXYGEN_OMIT_INTERNAL
573 
574  // With all submessage and field getters: Note that the returned reference
575  // should not be used after the lifetime of this parent.
576 
577  // Submessages ----------------
578 
580  CommandGains& positionGains() { return position_gains_; }
582  const CommandGains& positionGains() const { return position_gains_; }
584  CommandGains& velocityGains() { return velocity_gains_; }
586  const CommandGains& velocityGains() const { return velocity_gains_; }
588  CommandGains& effortGains() { return effort_gains_; }
590  const CommandGains& effortGains() const { return effort_gains_; }
591 
592  // Subfields ----------------
593 
595  FloatField& springConstant() { return spring_constant_; }
597  const FloatField& springConstant() const { return spring_constant_; }
600  FloatField& referencePosition() { return reference_position_; }
603  const FloatField& referencePosition() const { return reference_position_; }
605  FloatField& referenceEffort() { return reference_effort_; }
607  const FloatField& referenceEffort() const { return reference_effort_; }
609  FloatField& velocityLimitMin() { return velocity_limit_min_; }
611  const FloatField& velocityLimitMin() const { return velocity_limit_min_; }
613  FloatField& velocityLimitMax() { return velocity_limit_max_; }
615  const FloatField& velocityLimitMax() const { return velocity_limit_max_; }
617  FloatField& effortLimitMin() { return effort_limit_min_; }
619  const FloatField& effortLimitMin() const { return effort_limit_min_; }
621  FloatField& effortLimitMax() { return effort_limit_max_; }
623  const FloatField& effortLimitMax() const { return effort_limit_max_; }
625  HighResAngleField& positionLimitMin() { return position_limit_min_; }
627  const HighResAngleField& positionLimitMin() const { return position_limit_min_; }
629  HighResAngleField& positionLimitMax() { return position_limit_max_; }
631  const HighResAngleField& positionLimitMax() const { return position_limit_max_; }
633  EnumField<ControlStrategy>& controlStrategy() { return control_strategy_; }
635  const EnumField<ControlStrategy>& controlStrategy() const { return control_strategy_; }
637  EnumField<MstopStrategy>& mstopStrategy() { return mstop_strategy_; }
639  const EnumField<MstopStrategy>& mstopStrategy() const { return mstop_strategy_; }
641  EnumField<PositionLimitStrategy>& minPositionLimitStrategy() { return min_position_limit_strategy_; }
643  const EnumField<PositionLimitStrategy>& minPositionLimitStrategy() const { return min_position_limit_strategy_; }
645  EnumField<PositionLimitStrategy>& maxPositionLimitStrategy() { return max_position_limit_strategy_; }
647  const EnumField<PositionLimitStrategy>& maxPositionLimitStrategy() const { return max_position_limit_strategy_; }
648 
650  private:
651  CommandGains position_gains_;
652  CommandGains velocity_gains_;
653  CommandGains effort_gains_;
654 
655  FloatField spring_constant_;
656  FloatField reference_position_;
657  FloatField reference_effort_;
658  FloatField velocity_limit_min_;
659  FloatField velocity_limit_max_;
660  FloatField effort_limit_min_;
661  FloatField effort_limit_max_;
662  HighResAngleField position_limit_min_;
663  HighResAngleField position_limit_max_;
664  EnumField<ControlStrategy> control_strategy_;
665  EnumField<MstopStrategy> mstop_strategy_;
666  EnumField<PositionLimitStrategy> min_position_limit_strategy_;
667  EnumField<PositionLimitStrategy> max_position_limit_strategy_;
668  };
669 
671  class Imu final {
672  public:
673 #ifndef DOXYGEN_OMIT_INTERNAL
674  Imu(HebiCommandRef& internal)
675  : internal_(internal), accel_includes_gravity_(internal, HebiCommandBoolAccelIncludesGravity) {}
676 #endif // DOXYGEN_OMIT_INTERNAL
677 
678  // With all submessage and field getters: Note that the returned reference
679  // should not be used after the lifetime of this parent.
680 
681  // Subfields ----------------
682 
684  BoolField& accelIncludesGravity() { return accel_includes_gravity_; }
686  const BoolField& accelIncludesGravity() const { return accel_includes_gravity_; }
687 
689  private:
690  const HebiCommandRef& internal_;
691 
692  BoolField accel_includes_gravity_;
693  };
694 
695  public:
696 #ifndef DOXYGEN_OMIT_INTERNAL
697  Settings(HebiCommandPtr internal_ptr, HebiCommandRef& internal)
698  : internal_(internal),
699  actuator_(internal),
700  imu_(internal),
701  name_(internal_ptr, HebiCommandStringName),
702  family_(internal_ptr, HebiCommandStringFamily),
703  user_settings_bytes_1_(internal_ptr, HebiCommandStringUserSettingsBytes1),
704  user_settings_bytes_2_(internal_ptr, HebiCommandStringUserSettingsBytes2),
705  user_settings_bytes_3_(internal_ptr, HebiCommandStringUserSettingsBytes3),
706  user_settings_bytes_4_(internal_ptr, HebiCommandStringUserSettingsBytes4),
707  user_settings_bytes_5_(internal_ptr, HebiCommandStringUserSettingsBytes5),
708  user_settings_bytes_6_(internal_ptr, HebiCommandStringUserSettingsBytes6),
709  user_settings_bytes_7_(internal_ptr, HebiCommandStringUserSettingsBytes7),
710  user_settings_bytes_8_(internal_ptr, HebiCommandStringUserSettingsBytes8),
711  user_settings_float_1_(internal, HebiCommandFloatUserSettingsFloat1),
712  user_settings_float_2_(internal, HebiCommandFloatUserSettingsFloat2),
713  user_settings_float_3_(internal, HebiCommandFloatUserSettingsFloat3),
714  user_settings_float_4_(internal, HebiCommandFloatUserSettingsFloat4),
715  user_settings_float_5_(internal, HebiCommandFloatUserSettingsFloat5),
716  user_settings_float_6_(internal, HebiCommandFloatUserSettingsFloat6),
717  user_settings_float_7_(internal, HebiCommandFloatUserSettingsFloat7),
718  user_settings_float_8_(internal, HebiCommandFloatUserSettingsFloat8),
719  ip_address_(internal, HebiCommandUInt64IpAddress),
720  subnet_mask_(internal, HebiCommandUInt64SubnetMask),
721  save_current_settings_(internal, HebiCommandFlagSaveCurrentSettings) {}
722 #endif // DOXYGEN_OMIT_INTERNAL
723 
724  // With all submessage and field getters: Note that the returned reference
725  // should not be used after the lifetime of this parent.
726 
727  // Submessages ----------------
728 
730  Actuator& actuator() { return actuator_; }
732  const Actuator& actuator() const { return actuator_; }
734  Imu& imu() { return imu_; }
736  const Imu& imu() const { return imu_; }
737 
738  // Subfields ----------------
739 
742  StringField& name() { return name_; }
745  const StringField& name() const { return name_; }
748  StringField& family() { return family_; }
751  const StringField& family() const { return family_; }
755  {
756  switch (number) {
757  case 1: return user_settings_bytes_1_;
758  case 2: return user_settings_bytes_2_;
759  case 3: return user_settings_bytes_3_;
760  case 4: return user_settings_bytes_4_;
761  case 5: return user_settings_bytes_5_;
762  case 6: return user_settings_bytes_6_;
763  case 7: return user_settings_bytes_7_;
764  case 8: return user_settings_bytes_8_;
765  }
766  throw std::out_of_range("Invalid option for bytes array user setting entry!");
767  }
770  const StringField& userSettingsBytes(size_t number) const
771  {
772  switch (number) {
773  case 1: return user_settings_bytes_1_;
774  case 2: return user_settings_bytes_2_;
775  case 3: return user_settings_bytes_3_;
776  case 4: return user_settings_bytes_4_;
777  case 5: return user_settings_bytes_5_;
778  case 6: return user_settings_bytes_6_;
779  case 7: return user_settings_bytes_7_;
780  case 8: return user_settings_bytes_8_;
781  }
782  throw std::out_of_range("Invalid option for bytes array user setting entry!");
783  }
787  {
788  switch (number) {
789  case 1: return user_settings_float_1_;
790  case 2: return user_settings_float_2_;
791  case 3: return user_settings_float_3_;
792  case 4: return user_settings_float_4_;
793  case 5: return user_settings_float_5_;
794  case 6: return user_settings_float_6_;
795  case 7: return user_settings_float_7_;
796  case 8: return user_settings_float_8_;
797  }
798  throw std::out_of_range("Invalid option for float user setting entry!");
799  }
802  const FloatField& userSettingsFloat(size_t number) const
803  {
804  switch (number) {
805  case 1: return user_settings_float_1_;
806  case 2: return user_settings_float_2_;
807  case 3: return user_settings_float_3_;
808  case 4: return user_settings_float_4_;
809  case 5: return user_settings_float_5_;
810  case 6: return user_settings_float_6_;
811  case 7: return user_settings_float_7_;
812  case 8: return user_settings_float_8_;
813  }
814  throw std::out_of_range("Invalid option for float user setting entry!");
815  }
818  IpAddressField& ipAddress() { return ip_address_; }
821  const IpAddressField& ipAddress() const { return ip_address_; }
823  IpAddressField& subnetMask() { return subnet_mask_; }
825  const IpAddressField& subnetMask() const { return subnet_mask_; }
827  FlagField& saveCurrentSettings() { return save_current_settings_; }
829  const FlagField& saveCurrentSettings() const { return save_current_settings_; }
830 
832 
833  private:
834  HebiCommandRef& internal_;
835 
836  Actuator actuator_;
837  Imu imu_;
838 
839  StringField name_;
840  StringField family_;
841  StringField user_settings_bytes_1_;
842  StringField user_settings_bytes_2_;
843  StringField user_settings_bytes_3_;
844  StringField user_settings_bytes_4_;
845  StringField user_settings_bytes_5_;
846  StringField user_settings_bytes_6_;
847  StringField user_settings_bytes_7_;
848  StringField user_settings_bytes_8_;
849  FloatField user_settings_float_1_;
850  FloatField user_settings_float_2_;
851  FloatField user_settings_float_3_;
852  FloatField user_settings_float_4_;
853  FloatField user_settings_float_5_;
854  FloatField user_settings_float_6_;
855  FloatField user_settings_float_7_;
856  FloatField user_settings_float_8_;
857  IpAddressField ip_address_;
858  IpAddressField subnet_mask_;
859  FlagField save_current_settings_;
860  };
861 
863  class Actuator final {
864  public:
865 #ifndef DOXYGEN_OMIT_INTERNAL
866  Actuator(HebiCommandRef& internal)
867  : internal_(internal),
868  velocity_(internal, HebiCommandFloatVelocity),
869  effort_(internal, HebiCommandFloatEffort),
870  position_(internal, HebiCommandHighResAnglePosition) {}
871 #endif // DOXYGEN_OMIT_INTERNAL
872 
873  // With all submessage and field getters: Note that the returned reference
874  // should not be used after the lifetime of this parent.
875 
876  // Subfields ----------------
877 
879  FloatField& velocity() { return velocity_; }
881  const FloatField& velocity() const { return velocity_; }
883  FloatField& effort() { return effort_; }
885  const FloatField& effort() const { return effort_; }
887  HighResAngleField& position() { return position_; }
889  const HighResAngleField& position() const { return position_; }
890 
892  private:
893  const HebiCommandRef& internal_;
894 
895  FloatField velocity_;
896  FloatField effort_;
897  HighResAngleField position_;
898  };
899 
900 private:
905  HebiCommandPtr internal_;
906  HebiCommandRef internal_ref_;
907 
908 public:
909 #ifndef DOXYGEN_OMIT_INTERNAL
910 
914  Command(HebiCommandPtr);
915 #endif // DOXYGEN_OMIT_INTERNAL
916 
919  Command(Command&& other);
920 
921  // With all submessage and field getters: Note that the returned reference
922  // should not be used after the lifetime of this parent.
923 
924  // Submessages -------------------------------------------------------------
925 
927  Io& io() { return io_; }
929  const Io& io() const { return io_; }
931  Settings& settings() { return settings_; }
933  const Settings& settings() const { return settings_; }
935  Actuator& actuator() { return actuator_; }
937  const Actuator& actuator() const { return actuator_; }
938 
939  // Subfields -------------------------------------------------------------
940 
941 #ifndef DOXYGEN_OMIT_INTERNAL
942  NumberedFloatField& debug() { return debug_; }
945  const NumberedFloatField& debug() const { return debug_; }
946 #endif // DOXYGEN_OMIT_INTERNAL
947  StringField& appendLog() { return append_log_; }
950  const StringField& appendLog() const { return append_log_; }
952  FlagField& reset() { return reset_; }
954  const FlagField& reset() const { return reset_; }
956  FlagField& boot() { return boot_; }
958  const FlagField& boot() const { return boot_; }
960  FlagField& stopBoot() { return stop_boot_; }
962  const FlagField& stopBoot() const { return stop_boot_; }
964  FlagField& clearLog() { return clear_log_; }
966  const FlagField& clearLog() const { return clear_log_; }
968  LedField& led() { return led_; }
970  const LedField& led() const { return led_; }
971 
976 
977  /* Disable move assigment operator. */
978  Command& operator=(Command&& other) = delete;
979 
980 private:
981  Io io_;
982  Settings settings_;
983  Actuator actuator_;
984 
985  NumberedFloatField debug_;
986  StringField append_log_;
987  FlagField reset_;
988  FlagField boot_;
989  FlagField stop_boot_;
990  FlagField clear_log_;
991  LedField led_;
992 };
993 
994 } // namespace hebi
const FloatField & referencePosition() const
Definition: command.hpp:603
void clear()
Removes any currently set value for this field.
Definition: command.cpp:130
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:242
bool has() const
True if (and only if) the field has a value.
Definition: command.hpp:355
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:514
IoBank & f()
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:532
IpAddress get() const
If the field has a value, returns that value; otherwise, returns 0.0.0.0.
Definition: command.cpp:99
FlagField & reset()
Restart the module.
Definition: command.hpp:952
FlagField & saveCurrentSettings()
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:827
IoBank & d()
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:524
const EnumField< PositionLimitStrategy > & minPositionLimitStrategy() const
The position limit strategy (at the minimum position) for the actuator.
Definition: command.hpp:643
MstopStrategy
Definition: command.hpp:52
const FloatField & effortLimitMin() const
The firmware safety limit for the minimum allowed effort.
Definition: command.hpp:619
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:611
HighResAngleField & positionLimitMax()
The firmware safety limit for the maximum allowed position.
Definition: command.hpp:629
#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:202
A message field representable by a bool value.
Definition: command.hpp:246
Actuator & actuator()
Actuator-specific commands.
Definition: command.hpp:935
Actuator-specific commands.
Definition: command.hpp:863
void hebiCommandSetEnum(HebiCommandRef &command, HebiCommandEnumField field, const int32_t *value)
Definition: message_helpers.cpp:388
Io & io()
Any available digital or analog output pins on the device.
Definition: command.hpp:927
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:885
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:931
StringField & userSettingsBytes(size_t number)
Definition: command.hpp:754
const Io & io() const
Any available digital or analog output pins on the device.
Definition: command.hpp:929
FloatField & springConstant()
The spring constant of the module.
Definition: command.hpp:595
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:617
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:382
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:956
Actuator & actuator()
Actuator-specific settings, such as controller gains.
Definition: command.hpp:730
const HighResAngleField & position() const
Position of the module output (post-spring), in radians.
Definition: command.hpp:889
const IoBank & d() const
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:526
void setInt(size_t pinNumber, int64_t value)
Sets the particular pin to a integer value (representing a digital output).
Definition: command.cpp:190
StringField & family()
Definition: command.hpp:748
Command objects have various fields that can be set; when sent to the module, these fields control in...
Definition: command.hpp:34
const BoolField & accelIncludesGravity() const
Whether to include acceleration due to gravity in acceleration feedback.
Definition: command.hpp:686
IoBank & a()
I/O pin bank a (pins 1-8 available)
Definition: command.hpp:512
A message field representable by a std::string.
Definition: command.hpp:268
BoolField & accelIncludesGravity()
Whether to include acceleration due to gravity in acceleration feedback.
Definition: command.hpp:684
Definition: arm.cpp:8
FloatField & userSettingsFloat(size_t number)
Definition: command.hpp:786
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:198
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:823
void set()
Sets this flag.
Definition: command.cpp:164
A message field for interfacing with an LED.
Definition: command.hpp:454
const FlagField & clearLog() const
Clears the log message on the module.
Definition: command.hpp:966
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:623
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:825
const StringField & name() const
Definition: command.hpp:745
CommandGains & effortGains()
Controller gains for the effort PID loop.
Definition: command.hpp:588
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:6
const FlagField & reset() const
Restart the module.
Definition: command.hpp:954
const IoBank & c() const
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:522
IoBank & c()
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:520
const CommandGains & effortGains() const
Controller gains for the effort PID loop.
Definition: command.hpp:590
HighResAngleField & position()
Position of the module output (post-spring), in radians.
Definition: command.hpp:887
const FloatField & springConstant() const
The spring constant of the module.
Definition: command.hpp:597
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:635
CommandGains & velocityGains()
Controller gains for the velocity PID loop.
Definition: command.hpp:584
const IoBank & b() const
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:518
Actuator-specific settings, such as controller gains.
Definition: command.hpp:552
Module settings that are typically changed at a slower rate.
Definition: command.hpp:549
const CommandGains & positionGains() const
Controller gains for the position PID loop.
Definition: command.hpp:582
FloatField & referencePosition()
Definition: command.hpp:600
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:933
A two-state message field (either set/true or cleared/false).
Definition: command.hpp:303
void set(T _value)
Sets the field to a given value.
Definition: command.hpp:366
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:948
const Actuator & actuator() const
Actuator-specific settings, such as controller gains.
Definition: command.hpp:732
IoBank & b()
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:516
const IoBank & e() const
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:530
A message field containing a numbered set of single-precision floating point values.
Definition: command.hpp:174
Triggering the M-Stop has no effect.
HebiStatusCode enumGetter(const RefT &ref, MetadataT &metadata, int field, int32_t *value)
Definition: message_helpers.cpp:298
const FloatField & userSettingsFloat(size_t number) const
Definition: command.hpp:802
const StringField & family() const
Definition: command.hpp:751
Color get() const
Returns the current LED command.
Definition: command.cpp:231
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:178
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:958
FloatField & effortLimitMax()
The firmware safety limit for the maximum allowed effort.
Definition: command.hpp:621
EnumField< ControlStrategy > & controlStrategy()
How the position, velocity, and effort PID loops are connected in order to control motor PWM.
Definition: command.hpp:633
const LedField & led() const
The module's LED.
Definition: command.hpp:970
HighResAngleField & positionLimitMin()
The firmware safety limit for the minimum allowed position.
Definition: command.hpp:625
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:184
FloatField & velocity()
Velocity of the module output (post-spring), in radians/second.
Definition: command.hpp:879
Exceeding the position limit results in a virtual spring that pushes the actuator back to within the ...
const IpAddressField & ipAddress() const
Definition: command.hpp:821
Any available digital or analog output pins on the device.
Definition: command.hpp:494
const HighResAngleField & positionLimitMin() const
The firmware safety limit for the minimum allowed position.
Definition: command.hpp:627
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:605
ControlStrategy
Definition: command.hpp:36
const EnumField< PositionLimitStrategy > & maxPositionLimitStrategy() const
The position limit strategy (at the maximum position) for the actuator.
Definition: command.hpp:647
A simple wrapper class for IpAddress objects.
Definition: ip_address.hpp:34
const HighResAngleField & positionLimitMax() const
The firmware safety limit for the maximum allowed position.
Definition: command.hpp:631
const Imu & imu() const
IMU-specific settings.
Definition: command.hpp:736
const FloatField & referenceEffort() const
The internal effort reference offset (setting this matches the current effort to the given reference ...
Definition: command.hpp:607
const FlagField & saveCurrentSettings() const
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:829
void clear()
Removes any currently set value for this field.
Definition: command.hpp:371
IoBank & e()
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:528
FlagField & clearLog()
Clears the log message on the module.
Definition: command.hpp:964
EnumField< PositionLimitStrategy > & maxPositionLimitStrategy()
The position limit strategy (at the maximum position) for the actuator.
Definition: command.hpp:645
const EnumField< MstopStrategy > & mstopStrategy() const
The motion stop strategy for the actuator.
Definition: command.hpp:639
T get() const
If the field has a value, returns that value; otherwise, returns a default.
Definition: command.hpp:360
void clear()
Removes any currently set value for this field, so that the module maintains its previous state of LE...
Definition: command.cpp:246
Command(Command &&other)
Move constructor (necessary for containment in STL template classes)
Definition: command.cpp:250
A message field for an angle measurement which does not lose precision at very high angles.
Definition: command.hpp:113
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:734
const FlagField & stopBoot() const
Stop the module from automatically booting into application.
Definition: command.hpp:962
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:637
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: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:881
const Actuator & actuator() const
Actuator-specific commands.
Definition: command.hpp:937
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:613
const StringField & appendLog() const
Appends to the current log message on the module.
Definition: command.hpp:950
const FloatField & velocityLimitMax() const
The firmware safety limit for the maximum allowed velocity.
Definition: command.hpp:615
IMU-specific settings.
Definition: command.hpp:671
StringField & name()
Definition: command.hpp:742
LedField & led()
The module's LED.
Definition: command.hpp:968
void setFloat(size_t pinNumber, float value)
Sets the particular pin to a floating point value (representing a PWM output).
Definition: command.cpp:194
void setLabel(size_t pinNumber, const std::string &)
Sets the string label for a particular pin.
Definition: command.cpp:214
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:227
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:174
const CommandGains & velocityGains() const
Controller gains for the velocity PID loop.
Definition: command.hpp:586
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:170
const IoBank & f() const
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:534
A direct PWM value (-1 to 1) can be sent to the motor (subject to onboard safety limiting).
Structure to describe an RGB color.
Definition: color.hpp:8
CommandGains & positionGains()
Controller gains for the position PID loop.
Definition: command.hpp:580
A message field representable by an unsigned 64 bit integer value.
Definition: command.hpp:211
A message field representable by a single-precision floating point value.
Definition: command.hpp:74
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:61
const StringField & userSettingsBytes(size_t number) const
Definition: command.hpp:770
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:609
void clear(size_t pinNumber)
Removes any currently set value for this pin.
Definition: command.cpp:220
void set(const std::string &value)
Sets the field to a given value.
Definition: command.cpp:151
IpAddressField & ipAddress()
Definition: command.hpp:818
EnumField< PositionLimitStrategy > & minPositionLimitStrategy()
The position limit strategy (at the minimum position) for the actuator.
Definition: command.hpp:641
FlagField & stopBoot()
Stop the module from automatically booting into application.
Definition: command.hpp:960
A message field representable by an enum of a given type.
Definition: command.hpp:336
FloatField & effort()
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages).
Definition: command.hpp:883