HEBI C++ API  1.0.0-rc1
command.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "hebi_command.h"
4 #include "color.hpp"
5 #include <string>
6 #include "util.hpp"
7 
8 namespace hebi {
9 
29 class Command final
30 {
31  public:
34  Off,
43  };
44 
45  // Note: this is 'protected' instead of 'private' for easier use with Doxygen
46  protected:
48  class FloatField final
49  {
50  public:
51  #ifndef DOXYGEN_OMIT_INTERNAL
52  FloatField(HebiCommandPtr internal, HebiCommandFloatField field);
53  #endif // DOXYGEN_OMIT_INTERNAL
54  explicit operator bool() const;
68  bool has() const;
71  float get() const;
73  void set(float value);
75  void clear();
76 
77  private:
78  HebiCommandPtr const internal_;
79  HebiCommandFloatField const field_;
80 
82  };
88  class HighResAngleField final
89  {
90  public:
91  #ifndef DOXYGEN_OMIT_INTERNAL
92  HighResAngleField(HebiCommandPtr internal, HebiCommandHighResAngleField field);
93  #endif // DOXYGEN_OMIT_INTERNAL
94  explicit operator bool() const;
108  bool has() const;
114  double get() const;
126  void get(int64_t* revolutions, float* radian_offset) const;
131  void set(double radians);
138  void set(int64_t revolutions, float radian_offset);
140  void clear();
141 
142  private:
143  HebiCommandPtr const internal_;
144  HebiCommandHighResAngleField const field_;
145 
147  };
148 
151  class NumberedFloatField final
152  {
153  public:
154  #ifndef DOXYGEN_OMIT_INTERNAL
155  NumberedFloatField(HebiCommandPtr internal, HebiCommandNumberedFloatField field);
156  #endif // DOXYGEN_OMIT_INTERNAL
157  bool has(int fieldNumber) const;
168  float get(int fieldNumber) const;
174  void set(int fieldNumber, float value);
180  void clear(int fieldNumber);
181 
182  private:
183  HebiCommandPtr const internal_;
184  HebiCommandNumberedFloatField const field_;
185 
187  };
188 
190  class BoolField final
191  {
192  public:
193  #ifndef DOXYGEN_OMIT_INTERNAL
194  BoolField(HebiCommandPtr internal, HebiCommandBoolField field);
195  #endif // DOXYGEN_OMIT_INTERNAL
196  bool has() const;
200  bool get() const;
202  void set(bool value);
204  void clear();
205 
206  private:
207  HebiCommandPtr const internal_;
208  HebiCommandBoolField const field_;
209 
211  };
212 
214  class StringField final
215  {
216  public:
217  #ifndef DOXYGEN_OMIT_INTERNAL
218  StringField(HebiCommandPtr internal, HebiCommandStringField field);
219  #endif // DOXYGEN_OMIT_INTERNAL
220  explicit operator bool() const;
234  bool has() const;
237  std::string get() const;
239  void set(const std::string& value);
241  void clear();
242 
243  private:
244  HebiCommandPtr const internal_;
245  HebiCommandStringField const field_;
246 
248  };
249 
251  class FlagField final
252  {
253  public:
254  #ifndef DOXYGEN_OMIT_INTERNAL
255  FlagField(HebiCommandPtr internal, HebiCommandFlagField field);
256  #endif // DOXYGEN_OMIT_INTERNAL
257  explicit operator bool() const;
271  bool has() const;
273  void set();
275  void clear();
276 
277  private:
278  HebiCommandPtr const internal_;
279  HebiCommandFlagField const field_;
280 
282  };
283 
285  template <class T>
286  class EnumField final
287  {
288  public:
289  #ifndef DOXYGEN_OMIT_INTERNAL
290  EnumField(HebiCommandPtr internal, HebiCommandEnumField field)
291  : internal_(internal), field_(field) {}
292  #endif // DOXYGEN_OMIT_INTERNAL
293  explicit operator bool() const { return has(); }
307  bool has() const { return (hebiCommandGetEnum(internal_, field_, nullptr) == HebiStatusSuccess); }
310  T get() const { T ret; hebiCommandGetEnum(internal_, field_, reinterpret_cast<int*>(&ret)); return ret; }
312  void set(T value) { hebiCommandSetEnum(internal_, field_, reinterpret_cast<int*>(&value)); }
314  void clear() { hebiCommandSetEnum(internal_, field_, nullptr); }
315 
316  private:
317  HebiCommandPtr const internal_;
318  HebiCommandEnumField const field_;
319 
321  };
322 
324  class IoBank final
325  {
326  public:
327  #ifndef DOXYGEN_OMIT_INTERNAL
328  IoBank(HebiCommandPtr internal, HebiCommandIoPinBank bank);
329  #endif // DOXYGEN_OMIT_INTERNAL
330  bool hasInt(int pinNumber) const;
341  bool hasFloat(int pinNumber) const;
347  int64_t getInt(int pinNumber) const;
354  float getFloat(int pinNumber) const;
360  void setInt(int pinNumber, int64_t value);
366  void setFloat(int pinNumber, float value);
371  void clear(int pinNumber);
372 
373  private:
374  HebiCommandPtr const internal_;
375  HebiCommandIoPinBank const bank_;
376 
378  };
380  class LedField final
381  {
382  public:
383  #ifndef DOXYGEN_OMIT_INTERNAL
384  LedField(HebiCommandPtr internal, HebiCommandLedField field);
385  #endif // DOXYGEN_OMIT_INTERNAL
386  bool hasColor() const;
395  bool hasModuleControl() const;
397  Color getColor() const;
400  void setOverrideColor(const Color& new_color);
402  void setModuleControl();
407  void clear();
408 
409  private:
410  HebiCommandPtr const internal_;
411  HebiCommandLedField const field_;
412 
414  };
415 
417  class Io final
418  {
419  public:
420  #ifndef DOXYGEN_OMIT_INTERNAL
421  Io(HebiCommandPtr internal)
422  : internal_(internal),
423  a_(internal, HebiCommandIoBankA),
424  b_(internal, HebiCommandIoBankB),
425  c_(internal, HebiCommandIoBankC),
426  d_(internal, HebiCommandIoBankD),
427  e_(internal, HebiCommandIoBankE),
428  f_(internal, HebiCommandIoBankF)
429  {
430  }
431  #endif // DOXYGEN_OMIT_INTERNAL
432 
433  // With all submessage and field getters: Note that the returned reference
434  // should not be used after the lifetime of this parent.
435 
436  // Subfields ----------------
437 
439  IoBank& a() { return a_; }
441  const IoBank& a() const { return a_; }
443  IoBank& b() { return b_; }
445  const IoBank& b() const { return b_; }
447  IoBank& c() { return c_; }
449  const IoBank& c() const { return c_; }
451  IoBank& d() { return d_; }
453  const IoBank& d() const { return d_; }
455  IoBank& e() { return e_; }
457  const IoBank& e() const { return e_; }
459  IoBank& f() { return f_; }
461  const IoBank& f() const { return f_; }
462 
463  private:
464  HebiCommandPtr const internal_;
465 
466  IoBank a_;
467  IoBank b_;
468  IoBank c_;
469  IoBank d_;
470  IoBank e_;
471  IoBank f_;
472 
474  };
475 
477  class Settings final
478  {
479  // Note: this is 'protected' instead of 'private' for easier use with Doxygen
480  protected:
482  class Actuator final
483  {
484  // Note: this is 'protected' instead of 'private' for easier use with Doxygen
485  protected:
487  class PositionGains final
488  {
489  public:
490  #ifndef DOXYGEN_OMIT_INTERNAL
491  PositionGains(HebiCommandPtr internal)
492  : internal_(internal),
493  position_kp_(internal, HebiCommandFloatPositionKp),
494  position_ki_(internal, HebiCommandFloatPositionKi),
495  position_kd_(internal, HebiCommandFloatPositionKd),
496  position_feed_forward_(internal, HebiCommandFloatPositionFeedForward),
497  position_dead_zone_(internal, HebiCommandFloatPositionDeadZone),
498  position_i_clamp_(internal, HebiCommandFloatPositionIClamp),
499  position_punch_(internal, HebiCommandFloatPositionPunch),
500  position_min_target_(internal, HebiCommandFloatPositionMinTarget),
501  position_max_target_(internal, HebiCommandFloatPositionMaxTarget),
502  position_target_lowpass_(internal, HebiCommandFloatPositionTargetLowpass),
503  position_min_output_(internal, HebiCommandFloatPositionMinOutput),
504  position_max_output_(internal, HebiCommandFloatPositionMaxOutput),
505  position_output_lowpass_(internal, HebiCommandFloatPositionOutputLowpass),
506  position_d_on_error_(internal, HebiCommandBoolPositionDOnError)
507  {
508  }
509  #endif // DOXYGEN_OMIT_INTERNAL
510 
511  // With all submessage and field getters: Note that the returned reference
512  // should not be used after the lifetime of this parent.
513 
514  // Subfields ----------------
515 
517  FloatField& positionKp() { return position_kp_; }
519  const FloatField& positionKp() const { return position_kp_; }
521  FloatField& positionKi() { return position_ki_; }
523  const FloatField& positionKi() const { return position_ki_; }
525  FloatField& positionKd() { return position_kd_; }
527  const FloatField& positionKd() const { return position_kd_; }
529  FloatField& positionFeedForward() { return position_feed_forward_; }
531  const FloatField& positionFeedForward() const { return position_feed_forward_; }
533  FloatField& positionDeadZone() { return position_dead_zone_; }
535  const FloatField& positionDeadZone() const { return position_dead_zone_; }
537  FloatField& positionIClamp() { return position_i_clamp_; }
539  const FloatField& positionIClamp() const { return position_i_clamp_; }
541  FloatField& positionPunch() { return position_punch_; }
543  const FloatField& positionPunch() const { return position_punch_; }
545  FloatField& positionMinTarget() { return position_min_target_; }
547  const FloatField& positionMinTarget() const { return position_min_target_; }
549  FloatField& positionMaxTarget() { return position_max_target_; }
551  const FloatField& positionMaxTarget() const { return position_max_target_; }
553  FloatField& positionTargetLowpass() { return position_target_lowpass_; }
555  const FloatField& positionTargetLowpass() const { return position_target_lowpass_; }
557  FloatField& positionMinOutput() { return position_min_output_; }
559  const FloatField& positionMinOutput() const { return position_min_output_; }
561  FloatField& positionMaxOutput() { return position_max_output_; }
563  const FloatField& positionMaxOutput() const { return position_max_output_; }
565  FloatField& positionOutputLowpass() { return position_output_lowpass_; }
567  const FloatField& positionOutputLowpass() const { return position_output_lowpass_; }
569  BoolField& positionDOnError() { return position_d_on_error_; }
571  const BoolField& positionDOnError() const { return position_d_on_error_; }
572 
573  private:
574  HebiCommandPtr const internal_;
575 
576  FloatField position_kp_;
577  FloatField position_ki_;
578  FloatField position_kd_;
579  FloatField position_feed_forward_;
580  FloatField position_dead_zone_;
581  FloatField position_i_clamp_;
582  FloatField position_punch_;
583  FloatField position_min_target_;
584  FloatField position_max_target_;
585  FloatField position_target_lowpass_;
586  FloatField position_min_output_;
587  FloatField position_max_output_;
588  FloatField position_output_lowpass_;
589  BoolField position_d_on_error_;
590 
592  };
593 
595  class VelocityGains final
596  {
597  public:
598  #ifndef DOXYGEN_OMIT_INTERNAL
599  VelocityGains(HebiCommandPtr internal)
600  : internal_(internal),
601  velocity_kp_(internal, HebiCommandFloatVelocityKp),
602  velocity_ki_(internal, HebiCommandFloatVelocityKi),
603  velocity_kd_(internal, HebiCommandFloatVelocityKd),
604  velocity_feed_forward_(internal, HebiCommandFloatVelocityFeedForward),
605  velocity_dead_zone_(internal, HebiCommandFloatVelocityDeadZone),
606  velocity_i_clamp_(internal, HebiCommandFloatVelocityIClamp),
607  velocity_punch_(internal, HebiCommandFloatVelocityPunch),
608  velocity_min_target_(internal, HebiCommandFloatVelocityMinTarget),
609  velocity_max_target_(internal, HebiCommandFloatVelocityMaxTarget),
610  velocity_target_lowpass_(internal, HebiCommandFloatVelocityTargetLowpass),
611  velocity_min_output_(internal, HebiCommandFloatVelocityMinOutput),
612  velocity_max_output_(internal, HebiCommandFloatVelocityMaxOutput),
613  velocity_output_lowpass_(internal, HebiCommandFloatVelocityOutputLowpass),
614  velocity_d_on_error_(internal, HebiCommandBoolVelocityDOnError)
615  {
616  }
617  #endif // DOXYGEN_OMIT_INTERNAL
618 
619  // With all submessage and field getters: Note that the returned reference
620  // should not be used after the lifetime of this parent.
621 
622  // Subfields ----------------
623 
625  FloatField& velocityKp() { return velocity_kp_; }
627  const FloatField& velocityKp() const { return velocity_kp_; }
629  FloatField& velocityKi() { return velocity_ki_; }
631  const FloatField& velocityKi() const { return velocity_ki_; }
633  FloatField& velocityKd() { return velocity_kd_; }
635  const FloatField& velocityKd() const { return velocity_kd_; }
637  FloatField& velocityFeedForward() { return velocity_feed_forward_; }
639  const FloatField& velocityFeedForward() const { return velocity_feed_forward_; }
641  FloatField& velocityDeadZone() { return velocity_dead_zone_; }
643  const FloatField& velocityDeadZone() const { return velocity_dead_zone_; }
645  FloatField& velocityIClamp() { return velocity_i_clamp_; }
647  const FloatField& velocityIClamp() const { return velocity_i_clamp_; }
649  FloatField& velocityPunch() { return velocity_punch_; }
651  const FloatField& velocityPunch() const { return velocity_punch_; }
653  FloatField& velocityMinTarget() { return velocity_min_target_; }
655  const FloatField& velocityMinTarget() const { return velocity_min_target_; }
657  FloatField& velocityMaxTarget() { return velocity_max_target_; }
659  const FloatField& velocityMaxTarget() const { return velocity_max_target_; }
661  FloatField& velocityTargetLowpass() { return velocity_target_lowpass_; }
663  const FloatField& velocityTargetLowpass() const { return velocity_target_lowpass_; }
665  FloatField& velocityMinOutput() { return velocity_min_output_; }
667  const FloatField& velocityMinOutput() const { return velocity_min_output_; }
669  FloatField& velocityMaxOutput() { return velocity_max_output_; }
671  const FloatField& velocityMaxOutput() const { return velocity_max_output_; }
673  FloatField& velocityOutputLowpass() { return velocity_output_lowpass_; }
675  const FloatField& velocityOutputLowpass() const { return velocity_output_lowpass_; }
677  BoolField& velocityDOnError() { return velocity_d_on_error_; }
679  const BoolField& velocityDOnError() const { return velocity_d_on_error_; }
680 
681  private:
682  HebiCommandPtr const internal_;
683 
684  FloatField velocity_kp_;
685  FloatField velocity_ki_;
686  FloatField velocity_kd_;
687  FloatField velocity_feed_forward_;
688  FloatField velocity_dead_zone_;
689  FloatField velocity_i_clamp_;
690  FloatField velocity_punch_;
691  FloatField velocity_min_target_;
692  FloatField velocity_max_target_;
693  FloatField velocity_target_lowpass_;
694  FloatField velocity_min_output_;
695  FloatField velocity_max_output_;
696  FloatField velocity_output_lowpass_;
697  BoolField velocity_d_on_error_;
698 
700  };
701 
703  class EffortGains final
704  {
705  public:
706  #ifndef DOXYGEN_OMIT_INTERNAL
707  EffortGains(HebiCommandPtr internal)
708  : internal_(internal),
709  effort_kp_(internal, HebiCommandFloatEffortKp),
710  effort_ki_(internal, HebiCommandFloatEffortKi),
711  effort_kd_(internal, HebiCommandFloatEffortKd),
712  effort_feed_forward_(internal, HebiCommandFloatEffortFeedForward),
713  effort_dead_zone_(internal, HebiCommandFloatEffortDeadZone),
714  effort_i_clamp_(internal, HebiCommandFloatEffortIClamp),
715  effort_punch_(internal, HebiCommandFloatEffortPunch),
716  effort_min_target_(internal, HebiCommandFloatEffortMinTarget),
717  effort_max_target_(internal, HebiCommandFloatEffortMaxTarget),
718  effort_target_lowpass_(internal, HebiCommandFloatEffortTargetLowpass),
719  effort_min_output_(internal, HebiCommandFloatEffortMinOutput),
720  effort_max_output_(internal, HebiCommandFloatEffortMaxOutput),
721  effort_output_lowpass_(internal, HebiCommandFloatEffortOutputLowpass),
722  effort_d_on_error_(internal, HebiCommandBoolEffortDOnError)
723  {
724  }
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  FloatField& effortKp() { return effort_kp_; }
735  const FloatField& effortKp() const { return effort_kp_; }
737  FloatField& effortKi() { return effort_ki_; }
739  const FloatField& effortKi() const { return effort_ki_; }
741  FloatField& effortKd() { return effort_kd_; }
743  const FloatField& effortKd() const { return effort_kd_; }
745  FloatField& effortFeedForward() { return effort_feed_forward_; }
747  const FloatField& effortFeedForward() const { return effort_feed_forward_; }
749  FloatField& effortDeadZone() { return effort_dead_zone_; }
751  const FloatField& effortDeadZone() const { return effort_dead_zone_; }
753  FloatField& effortIClamp() { return effort_i_clamp_; }
755  const FloatField& effortIClamp() const { return effort_i_clamp_; }
757  FloatField& effortPunch() { return effort_punch_; }
759  const FloatField& effortPunch() const { return effort_punch_; }
761  FloatField& effortMinTarget() { return effort_min_target_; }
763  const FloatField& effortMinTarget() const { return effort_min_target_; }
765  FloatField& effortMaxTarget() { return effort_max_target_; }
767  const FloatField& effortMaxTarget() const { return effort_max_target_; }
769  FloatField& effortTargetLowpass() { return effort_target_lowpass_; }
771  const FloatField& effortTargetLowpass() const { return effort_target_lowpass_; }
773  FloatField& effortMinOutput() { return effort_min_output_; }
775  const FloatField& effortMinOutput() const { return effort_min_output_; }
777  FloatField& effortMaxOutput() { return effort_max_output_; }
779  const FloatField& effortMaxOutput() const { return effort_max_output_; }
781  FloatField& effortOutputLowpass() { return effort_output_lowpass_; }
783  const FloatField& effortOutputLowpass() const { return effort_output_lowpass_; }
785  BoolField& effortDOnError() { return effort_d_on_error_; }
787  const BoolField& effortDOnError() const { return effort_d_on_error_; }
788 
789  private:
790  HebiCommandPtr const internal_;
791 
792  FloatField effort_kp_;
793  FloatField effort_ki_;
794  FloatField effort_kd_;
795  FloatField effort_feed_forward_;
796  FloatField effort_dead_zone_;
797  FloatField effort_i_clamp_;
798  FloatField effort_punch_;
799  FloatField effort_min_target_;
800  FloatField effort_max_target_;
801  FloatField effort_target_lowpass_;
802  FloatField effort_min_output_;
803  FloatField effort_max_output_;
804  FloatField effort_output_lowpass_;
805  BoolField effort_d_on_error_;
806 
808  };
809 
810  public:
811  #ifndef DOXYGEN_OMIT_INTERNAL
812  Actuator(HebiCommandPtr internal)
813  : internal_(internal),
814  position_gains_(internal),
815  velocity_gains_(internal),
816  effort_gains_(internal),
817  spring_constant_(internal, HebiCommandFloatSpringConstant),
818  control_strategy_(internal, HebiCommandEnumControlStrategy)
819  {
820  }
821  #endif // DOXYGEN_OMIT_INTERNAL
822 
823  // With all submessage and field getters: Note that the returned reference
824  // should not be used after the lifetime of this parent.
825 
826  // Submessages ----------------
827 
829  PositionGains& positionGains() { return position_gains_; }
831  const PositionGains& positionGains() const { return position_gains_; }
833  VelocityGains& velocityGains() { return velocity_gains_; }
835  const VelocityGains& velocityGains() const { return velocity_gains_; }
837  EffortGains& effortGains() { return effort_gains_; }
839  const EffortGains& effortGains() const { return effort_gains_; }
840 
841  // Subfields ----------------
842 
844  FloatField& springConstant() { return spring_constant_; }
846  const FloatField& springConstant() const { return spring_constant_; }
848  EnumField<ControlStrategy>& controlStrategy() { return control_strategy_; }
850  const EnumField<ControlStrategy>& controlStrategy() const { return control_strategy_; }
851 
852  private:
853  HebiCommandPtr const internal_;
854 
855  PositionGains position_gains_;
856  VelocityGains velocity_gains_;
857  EffortGains effort_gains_;
858 
859  FloatField spring_constant_;
860  EnumField<ControlStrategy> control_strategy_;
861 
863  };
864 
865  public:
866  #ifndef DOXYGEN_OMIT_INTERNAL
867  Settings(HebiCommandPtr internal)
868  : internal_(internal),
869  actuator_(internal),
870  name_(internal, HebiCommandStringName),
871  family_(internal, HebiCommandStringFamily),
872  save_current_settings_(internal, HebiCommandFlagSaveCurrentSettings)
873  {
874  }
875  #endif // DOXYGEN_OMIT_INTERNAL
876 
877  // With all submessage and field getters: Note that the returned reference
878  // should not be used after the lifetime of this parent.
879 
880  // Submessages ----------------
881 
883  Actuator& actuator() { return actuator_; }
885  const Actuator& actuator() const { return actuator_; }
886 
887  // Subfields ----------------
888 
890  StringField& name() { return name_; }
892  const StringField& name() const { return name_; }
894  StringField& family() { return family_; }
896  const StringField& family() const { return family_; }
898  FlagField& saveCurrentSettings() { return save_current_settings_; }
900  const FlagField& saveCurrentSettings() const { return save_current_settings_; }
901 
902  private:
903  HebiCommandPtr const internal_;
904 
905  Actuator actuator_;
906 
907  StringField name_;
908  StringField family_;
909  FlagField save_current_settings_;
910 
912  };
913 
915  class Actuator final
916  {
917  public:
918  #ifndef DOXYGEN_OMIT_INTERNAL
919  Actuator(HebiCommandPtr internal)
920  : internal_(internal),
921  velocity_(internal, HebiCommandFloatVelocity),
922  effort_(internal, HebiCommandFloatEffort),
923  position_(internal, HebiCommandHighResAnglePosition)
924  {
925  }
926  #endif // DOXYGEN_OMIT_INTERNAL
927 
928  // With all submessage and field getters: Note that the returned reference
929  // should not be used after the lifetime of this parent.
930 
931  // Subfields ----------------
932 
934  FloatField& velocity() { return velocity_; }
936  const FloatField& velocity() const { return velocity_; }
938  FloatField& effort() { return effort_; }
940  const FloatField& effort() const { return effort_; }
942  HighResAngleField& position() { return position_; }
944  const HighResAngleField& position() const { return position_; }
945 
946  private:
947  HebiCommandPtr const internal_;
948 
949  FloatField velocity_;
950  FloatField effort_;
951  HighResAngleField position_;
952 
954  };
955 
956  private:
961  HebiCommandPtr internal_;
962 
963  public:
964  #ifndef DOXYGEN_OMIT_INTERNAL
965 
969  Command(HebiCommandPtr );
970  #endif // DOXYGEN_OMIT_INTERNAL
971 
974  Command(Command&& other);
978  virtual ~Command() noexcept; /* annotating specified destructor as noexcept is best-practice */
979 
980  // With all submessage and field getters: Note that the returned reference
981  // should not be used after the lifetime of this parent.
982 
983  // Submessages -------------------------------------------------------------
984 
986  Io& io() { return io_; }
988  const Io& io() const { return io_; }
990  Settings& settings() { return settings_; }
992  const Settings& settings() const { return settings_; }
994  Actuator& actuator() { return actuator_; }
996  const Actuator& actuator() const { return actuator_; }
997 
998  // Subfields -------------------------------------------------------------
999 
1000  #ifndef DOXYGEN_OMIT_INTERNAL
1001  NumberedFloatField& debug();
1004  const NumberedFloatField& debug() const;
1005  #endif // DOXYGEN_OMIT_INTERNAL
1006  LedField& led();
1009  const LedField& led() const;
1010 
1011  private:
1012  Io io_;
1013  Settings settings_;
1014  Actuator actuator_;
1015 
1016  NumberedFloatField debug_;
1017  LedField led_;
1018 
1023 
1024  /* Disable move assigment operator. */
1025  Command& operator= (const Command&& other) = delete;
1026 };
1027 
1028 } // namespace hebi
const FloatField & velocityIClamp() const
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:647
IoBank & f()
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:459
FlagField & saveCurrentSettings()
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:898
const FloatField & velocityKd() const
Derivative PID gain for velocity.
Definition: command.hpp:635
IoBank & d()
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:451
const FloatField & velocity() const
Velocity of the module output (post-spring), in radians/second.
Definition: command.hpp:936
FloatField & velocityMaxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:669
const BoolField & velocityDOnError() const
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: command.hpp:679
FloatField & velocityMinOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:665
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:940
Controller gains for the velocity PID loop.
Definition: command.hpp:595
#define HEBI_DISABLE_COPY(Class)
Definition: util.hpp:17
FloatField & positionKi()
Integral PID gain for position.
Definition: command.hpp:521
const FloatField & springConstant() const
The spring constant of the module.
Definition: command.hpp:846
void clear()
Removes any currently set value for this field.
Definition: command.cpp:40
A message field representable by a bool value.
Definition: command.hpp:190
const FloatField & velocityOutputLowpass() const
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:675
Actuator & actuator()
Actuator-specific commands.
Definition: command.hpp:994
A combination of the position, velocity, and effort loops with P, V, and T feeding to PWM; documented...
Definition: command.hpp:40
Actuator-specific commands.
Definition: command.hpp:915
Io & io()
Any available digital or analog output pins on the device.
Definition: command.hpp:986
Settings & settings()
Module settings that are typically changed at a slower rate.
Definition: command.hpp:990
const StringField & name() const
Sets the name for this module. Name must be null-terminated character string for the name; must be <=...
Definition: command.hpp:892
const FloatField & effortIClamp() const
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:755
FloatField & springConstant()
The spring constant of the module.
Definition: command.hpp:844
const FloatField & positionOutputLowpass() const
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:567
A combination of the position, velocity, and effort loops with P and V feeding to T; documented on do...
Definition: command.hpp:38
const FloatField & effortMinTarget() const
Minimum allowed value for input to the PID controller.
Definition: command.hpp:763
const FloatField & positionIClamp() const
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:539
A message field for interfacing with a bank of I/O pins.
Definition: command.hpp:324
const Actuator & actuator() const
Actuator-specific commands.
Definition: command.hpp:996
Actuator & actuator()
Actuator-specific settings, such as controller gains.
Definition: command.hpp:883
FloatField & effortFeedForward()
Feed forward term for effort (this term is multiplied by the target and added to the output)...
Definition: command.hpp:745
StringField & family()
Sets the family for this module. Name must be null-terminated character string for the family; must b...
Definition: command.hpp:894
Command objects have various fields that can be set; when sent to the module, these fields control in...
Definition: command.hpp:29
virtual ~Command() noexcept
Cleans up command object as necessary.
Definition: command.cpp:322
IoBank & a()
I/O pin bank a (pins 1-8 available)
Definition: command.hpp:439
A message field representable by a std::string.
Definition: command.hpp:214
FloatField & effortPunch()
Constant offset to the effort PID output outside of the deadzone; it is added when the error is posit...
Definition: command.hpp:757
Definition: color.hpp:5
FloatField & effortDeadZone()
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:749
const FloatField & effortFeedForward() const
Feed forward term for effort (this term is multiplied by the target and added to the output)...
Definition: command.hpp:747
const FloatField & effortPunch() const
Constant offset to the effort PID output outside of the deadzone; it is added when the error is posit...
Definition: command.hpp:759
A message field for interfacing with an LED.
Definition: command.hpp:380
FloatField & positionMaxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:561
const FloatField & effortKd() const
Derivative PID gain for effort.
Definition: command.hpp:743
BoolField & effortDOnError()
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: command.hpp:785
bool has() const
True if (and only if) the field has a value.
Definition: command.hpp:307
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:7
FloatField & positionPunch()
Constant offset to the position PID output outside of the deadzone; it is added when the error is pos...
Definition: command.hpp:541
const FloatField & effortTargetLowpass() const
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:771
const BoolField & positionDOnError() const
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: command.hpp:571
FloatField & velocityDeadZone()
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:641
FloatField & velocityPunch()
Constant offset to the velocity PID output outside of the deadzone; it is added when the error is pos...
Definition: command.hpp:649
IoBank & c()
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:447
FloatField & velocityKp()
Proportional PID gain for velocity.
Definition: command.hpp:625
HighResAngleField & position()
Position of the module output (post-spring), in radians.
Definition: command.hpp:942
FloatField & positionDeadZone()
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:533
VelocityGains & velocityGains()
Controller gains for the velocity PID loop.
Definition: command.hpp:833
PositionGains & positionGains()
Controller gains for the position PID loop.
Definition: command.hpp:829
const VelocityGains & velocityGains() const
Controller gains for the velocity PID loop.
Definition: command.hpp:835
Actuator-specific settings, such as controller gains.
Definition: command.hpp:482
const Io & io() const
Any available digital or analog output pins on the device.
Definition: command.hpp:988
FloatField & effortMinTarget()
Minimum allowed value for input to the PID controller.
Definition: command.hpp:761
FloatField & effortTargetLowpass()
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:769
const FloatField & positionMinOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:559
FloatField & velocityMinTarget()
Minimum allowed value for input to the PID controller.
Definition: command.hpp:653
Module settings that are typically changed at a slower rate.
Definition: command.hpp:477
const FloatField & positionTargetLowpass() const
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:555
FloatField & positionMaxTarget()
Maximum allowed value for input to the PID controller.
Definition: command.hpp:549
A two-state message field (either set/true or cleared/false).
Definition: command.hpp:251
const FloatField & positionKi() const
Integral PID gain for position.
Definition: command.hpp:523
const FloatField & velocityFeedForward() const
Feed forward term for velocity (this term is multiplied by the target and added to the output)...
Definition: command.hpp:639
const FloatField & velocityMaxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:671
const IoBank & e() const
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:457
const FloatField & effortOutputLowpass() const
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:783
IoBank & b()
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:443
BoolField & positionDOnError()
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: command.hpp:569
A message field containing a numbered set of single-precision floating point values.
Definition: command.hpp:151
const Settings & settings() const
Module settings that are typically changed at a slower rate.
Definition: command.hpp:992
A combination of the position, velocity, and effort loops with P feeding to T and V feeding to PWM; d...
Definition: command.hpp:42
FloatField & effortOutputLowpass()
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:781
const FloatField & velocityMinTarget() const
Minimum allowed value for input to the PID controller.
Definition: command.hpp:655
const IoBank & c() const
I/O pin bank c (pins 1-8 available)
Definition: command.hpp:449
FloatField & positionMinTarget()
Minimum allowed value for input to the PID controller.
Definition: command.hpp:545
const IoBank & b() const
I/O pin bank b (pins 1-8 available)
Definition: command.hpp:445
const FloatField & positionFeedForward() const
Feed forward term for position (this term is multiplied by the target and added to the output)...
Definition: command.hpp:531
FloatField & positionFeedForward()
Feed forward term for position (this term is multiplied by the target and added to the output)...
Definition: command.hpp:529
const FloatField & positionKd() const
Derivative PID gain for position.
Definition: command.hpp:527
const FloatField & velocityMaxTarget() const
Maximum allowed value for input to the PID controller.
Definition: command.hpp:659
FloatField & velocityTargetLowpass()
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:661
FloatField & positionIClamp()
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:537
const FloatField & velocityKp() const
Proportional PID gain for velocity.
Definition: command.hpp:627
EnumField< ControlStrategy > & controlStrategy()
How the position, velocity, and effort PID loops are connected in order to control motor PWM...
Definition: command.hpp:848
FloatField & velocityOutputLowpass()
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:673
A direct PWM value (-1 to 1) can be sent to the motor (subject to onboard safety limiting).
Definition: command.hpp:36
FloatField & velocity()
Velocity of the module output (post-spring), in radians/second.
Definition: command.hpp:934
const BoolField & effortDOnError() const
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: command.hpp:787
Any available digital or analog output pins on the device.
Definition: command.hpp:417
FloatField & velocityIClamp()
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:645
const FloatField & velocityMinOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:667
EffortGains & effortGains()
Controller gains for the effort PID loop.
Definition: command.hpp:837
const IoBank & d() const
I/O pin bank d (pins 1-8 available)
Definition: command.hpp:453
ControlStrategy
Definition: command.hpp:32
FloatField & effortKi()
Integral PID gain for effort.
Definition: command.hpp:737
void clear()
Removes any currently set value for this field.
Definition: command.hpp:314
FloatField & positionKd()
Derivative PID gain for position.
Definition: command.hpp:525
IoBank & e()
I/O pin bank e (pins 1-8 available)
Definition: command.hpp:455
FloatField & effortKp()
Proportional PID gain for effort.
Definition: command.hpp:733
const FloatField & velocityTargetLowpass() const
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:663
bool has() const
True if (and only if) the field has a value.
Definition: command.cpp:20
FloatField & velocityKd()
Derivative PID gain for velocity.
Definition: command.hpp:633
FloatField & positionTargetLowpass()
A simple lowpass filter applied to the target set point; needs to be between 0 and 1...
Definition: command.hpp:553
Command(Command &&other)
Move constructor (necessary for containment in STL template classes)
Definition: command.cpp:313
A message field for an angle measurement which does not lose precision at very high angles...
Definition: command.hpp:88
const FloatField & positionKp() const
Proportional PID gain for position.
Definition: command.hpp:519
const FloatField & positionDeadZone() const
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:535
const FloatField & positionMaxTarget() const
Maximum allowed value for input to the PID controller.
Definition: command.hpp:551
const FloatField & positionPunch() const
Constant offset to the position PID output outside of the deadzone; it is added when the error is pos...
Definition: command.hpp:543
FloatField & velocityFeedForward()
Feed forward term for velocity (this term is multiplied by the target and added to the output)...
Definition: command.hpp:637
const FloatField & velocityKi() const
Integral PID gain for velocity.
Definition: command.hpp:631
FloatField & effortKd()
Derivative PID gain for effort.
Definition: command.hpp:741
const FloatField & effortKi() const
Integral PID gain for effort.
Definition: command.hpp:739
const FloatField & velocityDeadZone() const
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:643
const FloatField & effortMaxTarget() const
Maximum allowed value for input to the PID controller.
Definition: command.hpp:767
FloatField & velocityKi()
Integral PID gain for velocity.
Definition: command.hpp:629
FloatField & positionMinOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:557
FloatField & effortIClamp()
Maximum allowed value for the output of the integral component of the PID loop; the integrated error ...
Definition: command.hpp:753
const FloatField & effortDeadZone() const
Error values within +/- this value from zero are treated as zero (in terms of computed proportional o...
Definition: command.hpp:751
FloatField & effortMinOutput()
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:773
const PositionGains & positionGains() const
Controller gains for the position PID loop.
Definition: command.hpp:831
StringField & name()
Sets the name for this module. Name must be null-terminated character string for the name; must be <=...
Definition: command.hpp:890
const FloatField & effortMaxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:779
FloatField & positionOutputLowpass()
A simple lowpass filter applied to the controller output; needs to be between 0 and 1...
Definition: command.hpp:565
FloatField & velocityMaxTarget()
Maximum allowed value for input to the PID controller.
Definition: command.hpp:657
FloatField & effortMaxOutput()
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:777
const IoBank & f() const
I/O pin bank f (pins 1-8 available)
Definition: command.hpp:461
const FlagField & saveCurrentSettings() const
Indicates if the module should save the current values of all of its settings.
Definition: command.hpp:900
Controller gains for the position PID loop.
Definition: command.hpp:487
const IoBank & a() const
I/O pin bank a (pins 1-8 available)
Definition: command.hpp:441
const EnumField< ControlStrategy > & controlStrategy() const
How the position, velocity, and effort PID loops are connected in order to control motor PWM...
Definition: command.hpp:850
const Actuator & actuator() const
Actuator-specific settings, such as controller gains.
Definition: command.hpp:885
The motor is not given power (equivalent to a 0 PWM value)
Definition: command.hpp:34
Structure to describe an RGB color.
Definition: color.hpp:8
const FloatField & effortMinOutput() const
Output from the PID controller is limited to a minimum of this value.
Definition: command.hpp:775
const StringField & family() const
Sets the family for this module. Name must be null-terminated character string for the family; must b...
Definition: command.hpp:896
BoolField & velocityDOnError()
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: command.hpp:677
const FloatField & velocityPunch() const
Constant offset to the velocity PID output outside of the deadzone; it is added when the error is pos...
Definition: command.hpp:651
FloatField & effortMaxTarget()
Maximum allowed value for input to the PID controller.
Definition: command.hpp:765
const FloatField & positionMaxOutput() const
Output from the PID controller is limited to a maximum of this value.
Definition: command.hpp:563
A message field representable by a single-precision floating point value.
Definition: command.hpp:48
const FloatField & effortKp() const
Proportional PID gain for effort.
Definition: command.hpp:735
const HighResAngleField & position() const
Position of the module output (post-spring), in radians.
Definition: command.hpp:944
FloatField & positionKp()
Proportional PID gain for position.
Definition: command.hpp:517
const FloatField & positionMinTarget() const
Minimum allowed value for input to the PID controller.
Definition: command.hpp:547
Controller gains for the effort PID loop.
Definition: command.hpp:703
const EffortGains & effortGains() const
Controller gains for the effort PID loop.
Definition: command.hpp:839
A message field representable by an enum of a given type.
Definition: command.hpp:286
FloatField & effort()
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages)...
Definition: command.hpp:938
LedField & led()
The module&#39;s LED.
Definition: command.cpp:342