Class Command
Defined in File command.hpp
Nested Relationships
Nested Types
Class Documentation
-
class Command
Command objects have various fields that can be set; when sent to the module, these fields control internal properties and setpoints.
This object has a hierarchical structure — there are some direct general-purpose fields at the top level, and many more specific fields contained in different nested subobjects.
The subobjects contain references to the parent command object, and so should not be used after the parent object has been destroyed.
The fields in the command object are typed; generally, these are optional-style read/write fields (i.e., have the concept of get/set/has/clear), although the return types and exact interface vary slightly between fields. Where appropriate, the explicit bool operator has been overridden so that you can shortcut
if
(field.has()) by callingif(field)
.Although this header file can be used to look at the hierarchy of the messages, in general the online documentation at apidocs.hebi.us presents this information. in a more readable form.
Public Types
-
enum class ControlStrategy
Values:
-
enumerator Off
The motor is not given power (equivalent to a 0 PWM value)
-
enumerator DirectPWM
A direct PWM value (-1 to 1) can be sent to the motor (subject to onboard safety limiting).
-
enumerator Strategy2
A combination of the position, velocity, and effort loops with P and V feeding to T; documented on docs.hebi.us under “Control Modes”
-
enumerator Strategy3
A combination of the position, velocity, and effort loops with P, V, and T feeding to PWM; documented on docs.hebi.us under “Control Modes”
-
enumerator Strategy4
A combination of the position, velocity, and effort loops with P feeding to T and V feeding to PWM; documented on docs.hebi.us under “Control Modes”
-
enumerator Strategy5
A combination of the position, velocity, and effort loops with P and V feeding to T; only supported for actuators supporting field-oriented motor control. Documented on docs.hebi.us under “Control Modes”
-
enumerator Off
-
enum class MstopStrategy
Values:
-
enumerator Disabled
Triggering the M-Stop has no effect.
-
enumerator MotorOff
Triggering the M-Stop results in the control strategy being set to ‘off’. Remains ‘off’ until changed by user.
-
enumerator HoldPosition
Triggering the M-Stop results in the motor holding the motor position. Operations resume to normal once trigger is released.
-
enumerator Disabled
-
enum class PositionLimitStrategy
Values:
-
enumerator HoldPosition
Exceeding the position limit results in the actuator holding the position. Needs to be manually set to ‘disabled’ to recover.
-
enumerator DampedSpring
Exceeding the position limit results in a virtual spring that pushes the actuator back to within the limits.
-
enumerator MotorOff
Exceeding the position limit results in the control strategy being set to ‘off’. Remains ‘off’ until changed by user.
-
enumerator Disabled
Exceeding the position limit has no effect.
-
enumerator HoldPosition
Public Functions
-
Command(HebiCommandPtr)
Wraps an existing C-style object that is managed by its parent. NOTE: this should not be used except by internal library functions!
-
inline const Settings &settings() const
Module settings that are typically changed at a slower rate.
-
inline NumberedFloatField &debug()
Values for internal debug functions (channel 1-9 available).
-
inline const NumberedFloatField &debug() const
Values for internal debug functions (channel 1-9 available).
-
inline StringField &appendLog()
Appends to the current log message on the module.
-
inline const StringField &appendLog() const
Appends to the current log message on the module.
Protected Types
-
using CommandGains = Gains<HebiCommandRef, FloatField, BoolField, HebiCommandFloatField, HebiCommandBoolField>
-
class Actuator
Actuator-specific commands.
Public Functions
-
inline Actuator(HebiCommandRef &internal)
-
inline FloatField &velocity()
Velocity of the module output (post-spring), in radians/second.
-
inline const FloatField &velocity() const
Velocity of the module output (post-spring), in radians/second.
-
inline FloatField &effort()
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages).
-
inline const FloatField &effort() const
Effort at the module output; units vary (e.g., N * m for rotational joints and N for linear stages).
-
inline HighResAngleField &position()
Position of the module output (post-spring), in radians.
-
inline const HighResAngleField &position() const
Position of the module output (post-spring), in radians.
-
inline Actuator(HebiCommandRef &internal)
-
class BoolField
A message field representable by a bool value.
Public Functions
-
BoolField(HebiCommandRef &internal, HebiCommandBoolField field)
-
bool has() const
True if (and only if) the field has a value.
-
bool get() const
If the field has a value, returns that value; otherwise, returns false.
-
void set(bool value)
Sets the field to a given value.
-
void clear()
Removes any currently set value for this field.
-
BoolField(HebiCommandRef &internal, HebiCommandBoolField field)
-
template<typename T>
class EnumField A message field representable by an enum of a given type.
Public Functions
-
inline EnumField(HebiCommandRef &internal, HebiCommandEnumField field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the field has a value without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::EnumField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
inline bool has() const
True if (and only if) the field has a value.
-
inline void clear()
Removes any currently set value for this field.
-
inline EnumField(HebiCommandRef &internal, HebiCommandEnumField field)
-
class FlagField
A two-state message field (either set/true or cleared/false).
Public Functions
-
FlagField(HebiCommandRef &internal, HebiCommandFlagField field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the flag is set without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::FlagField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
bool has() const
Returns
true
if the flag is set, false if it is cleared.
-
void set()
Sets this flag.
-
void clear()
Clears this flag (e.g., sets it to false/off).
-
FlagField(HebiCommandRef &internal, HebiCommandFlagField field)
-
class FloatField
A message field representable by a single-precision floating point value.
Public Functions
-
FloatField(HebiCommandRef &internal, HebiCommandFloatField field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the field has a value without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::FloatField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
bool has() const
True if (and only if) the field has a value.
-
float get() const
If the field has a value, returns that value; otherwise, returns a default.
-
void set(float value)
Sets the field to a given value.
-
void clear()
Removes any currently set value for this field.
-
FloatField(HebiCommandRef &internal, HebiCommandFloatField field)
-
class HighResAngleField
A message field for an angle measurement which does not lose precision at very high angles.
This field is represented as an int64_t for the number of revolutions and a float for the radian offset from that number of revolutions.
Public Functions
-
HighResAngleField(HebiCommandRef &internal, HebiCommandHighResAngleField field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the field has a value without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::HighResAngleField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
bool has() const
True if (and only if) the field has a value.
-
double get() const
If the field has a value, returns that value as a double; otherwise, returns a default.
Note that some precision might be lost converting to a double at very high number of revolutions.
-
void get(int64_t *revolutions, float *radian_offset) const
If the field has a value, returns that value in the int64 and float parameters passed in; otherwise, returns a default.
Note that this maintains the full precision of the underlying angle measurement, even for very large numbers of revolutions.
- Parameters:
revolutions – The number of full revolutions
radian_offset – The offset from the given number of full revolutions. Note that this is usually between 0 and
2*M_PI
, but callers should not assume this.
-
void set(double radians)
Sets the field to a given double value (in radians). Note that double precision floating point numbers cannot represent the same angular resolution at very high magnitudes as they can at lower magnitudes.
-
void set(int64_t revolutions, float radian_offset)
Sets the field to a given integer number of revolutions and a floating point offset from this number of revolutions. The offset does not specifically need to fall within a certain range (i.e., can add more than a single revolution to the integer value), but should be kept relatively small (e.g., below 10,000) to avoid potential loss of precision.
-
void clear()
Removes any currently set value for this field.
-
HighResAngleField(HebiCommandRef &internal, HebiCommandHighResAngleField field)
-
class Io
Any available digital or analog output pins on the device.
Public Functions
-
inline Io(HebiCommandPtr internal, HebiCommandRef &internal_ref)
-
inline Io(HebiCommandPtr internal, HebiCommandRef &internal_ref)
-
class IoBank
A message field for interfacing with a bank of I/O pins.
Public Functions
-
IoBank(HebiCommandPtr internal, HebiCommandRef &internal_ref, HebiCommandIoPinBank bank)
-
bool hasInt(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an integer (e.g., digital) value.
- Parameters:
pinNumber – Which pin to check; valid values for pinNumber depend on the bank.
-
bool hasFloat(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an floating point (e.g., analog or PWM) value.
- Parameters:
pinNumber – Which pin to check; valid values for pinNumber depend on the bank.
-
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 returns a default.
- Parameters:
pinNumber – Which pin to get; valid values for pinNumber depend on the bank.
-
float getFloat(size_t pinNumber) const
If this numbered pin in this bank has an floating point (e.g., analog or PWM) value, returns that value; otherwise returns a default.
- Parameters:
pinNumber – Which pin to get; valid values for pinNumber depend on the bank.
-
void setInt(size_t pinNumber, int64_t value)
Sets the particular pin to a integer value (representing a digital output).
- Parameters:
pinNumber – Which pin to set; valid values for pinNumber depend on the bank.
-
void setFloat(size_t pinNumber, float value)
Sets the particular pin to a floating point value (representing a PWM output).
- Parameters:
pinNumber – Which pin to set; valid values for pinNumber depend on the bank.
-
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.
- Parameters:
pinNumber – Which pin to set; valid values for pinNumber depend on the bank.
-
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 empty string.
- Parameters:
pinNumber – Which pin to get; valid values for pinNumber depend on the bank.
-
void setLabel(size_t pinNumber, const std::string&)
Sets the string label for a particular pin.
- Parameters:
pinNumber – Which pin to set; valid values for pinNumber depend on the bank.
-
void clear(size_t pinNumber)
Removes any currently set value for this pin.
- Parameters:
pinNumber – Which pin to clear; valid values for pinNumber depend on the bank.
-
IoBank(HebiCommandPtr internal, HebiCommandRef &internal_ref, HebiCommandIoPinBank bank)
-
class IpAddressField
A message field representable by an unsigned 64 bit integer value.
Public Functions
-
IpAddressField(HebiCommandRef &internal, HebiCommandUInt64Field field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the field has a value without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::IpAddressField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
bool has() const
True if (and only if) the field has a value.
-
void clear()
Removes any currently set value for this field.
-
IpAddressField(HebiCommandRef &internal, HebiCommandUInt64Field field)
-
class LedField
A message field for interfacing with an LED.
Public Functions
-
LedField(HebiCommandRef &internal, HebiCommandLedField field)
-
bool has() const
Returns true if the LED command has been set, and false otherwise.
A command is “set” if there is an override color specified or if the module is being commanded to resume control of the LED. If this returns
false
, it indicates that the current state of the LED will be maintained.
-
Color get() const
Returns the current LED command.
If the alpha channel is ‘0’, this command indicates that the module should resume control of the LED (and the R, G, and B values are ignored). If the alpha channel is ‘1’, the R, G, and B values in this command will override the module’s control of the LED.
-
void set(const Color &color)
Commands a color that overrides the module’s control of the LED (if the alpha channel is 255), or specifies the the module should resume control of the LED color (if the alpha channel is 0). Values of the alpha channel from 1 to 254 are reserved for future use.
-
void clear()
Removes any currently set value for this field, so that the module maintains its previous state of LED control/color (i.e., does not have an override color command or an explicit ‘module control’ command).
-
LedField(HebiCommandRef &internal, HebiCommandLedField field)
-
class NumberedFloatField
A message field containing a numbered set of single-precision floating point values.
Public Functions
-
NumberedFloatField(HebiCommandRef &internal, HebiCommandNumberedFloatField field)
-
bool has(size_t fieldNumber) const
True if (and only if) the particular numbered subvalue of this field has a value.
- Parameters:
fieldNumber – Which subvalue to check; valid values for fieldNumber depend on the field type.
-
float get(size_t fieldNumber) const
If the particular numbered subvalue of this field has a value, returns that value; otherwise returns a default.
- Parameters:
fieldNumber – Which subvalue to get; valid values for fieldNumber depend on the field type.
-
void set(size_t fieldNumber, float value)
Sets the particular numbered subvalue of this field to a given value.
- Parameters:
fieldNumber – Which subvalue to set; valid values for fieldNumber depend on the field type.
-
void clear(size_t fieldNumber)
Removes any currently set value for the numbered subvalue of this field.
- Parameters:
fieldNumber – Which subvalue to clear; valid values for fieldNumber depend on the field type.
-
NumberedFloatField(HebiCommandRef &internal, HebiCommandNumberedFloatField field)
-
class Settings
Module settings that are typically changed at a slower rate.
Public Functions
-
inline Settings(HebiCommandPtr internal_ptr, HebiCommandRef &internal)
-
inline StringField &name()
Sets the name for this module. Name must be null-terminated character string for the name; must be <= 20 characters.
-
inline const StringField &name() const
Sets the name for this module. Name must be null-terminated character string for the name; must be <= 20 characters.
-
inline StringField &family()
Sets the family for this module. Name must be null-terminated character string for the family; must be <= 20 characters.
-
inline const StringField &family() const
Sets the family for this module. Name must be null-terminated character string for the family; must be <= 20 characters.
-
inline StringField &userSettingsBytes(size_t number)
Sets the given byte array user setting; valid for entry number 1-8. Throws out of range if given an invalid index
-
inline const StringField &userSettingsBytes(size_t number) const
Sets the given byte array user setting; valid for entry number 1-8. Throws out of range if given an invalid index
-
inline FloatField &userSettingsFloat(size_t number)
Sets the given float user setting; valid for entry number 1-8. Throws out of range if given an invalid index
-
inline const FloatField &userSettingsFloat(size_t number) const
Sets the given float user setting; valid for entry number 1-8. Throws out of range if given an invalid index
-
inline IpAddressField &ipAddress()
Sets the static IP address for this module; must be set in conjunction with the subnet mask. Can be set to 0.0.0.0 to reset to DHCP.
-
inline const IpAddressField &ipAddress() const
Sets the static IP address for this module; must be set in conjunction with the subnet mask. Can be set to 0.0.0.0 to reset to DHCP.
-
inline IpAddressField &subnetMask()
Sets the subnet mask for this module; must be used with IP Address if setting a static IP address.
-
inline const IpAddressField &subnetMask() const
Sets the subnet mask for this module; must be used with IP Address if setting a static IP address.
-
class Actuator
Actuator-specific settings, such as controller gains.
Public Functions
-
inline Actuator(HebiCommandRef &internal)
-
inline CommandGains &positionGains()
Controller gains for the position PID loop.
-
inline const CommandGains &positionGains() const
Controller gains for the position PID loop.
-
inline CommandGains &velocityGains()
Controller gains for the velocity PID loop.
-
inline const CommandGains &velocityGains() const
Controller gains for the velocity PID loop.
-
inline CommandGains &effortGains()
Controller gains for the effort PID loop.
-
inline const CommandGains &effortGains() const
Controller gains for the effort PID loop.
-
inline FloatField &springConstant()
The spring constant of the module.
-
inline const FloatField &springConstant() const
The spring constant of the module.
-
inline FloatField &referencePosition()
The internal encoder reference offset (setting this matches the current position to the given reference command)
-
inline const FloatField &referencePosition() const
The internal encoder reference offset (setting this matches the current position to the given reference command)
-
inline FloatField &referenceEffort()
The internal effort reference offset (setting this matches the current effort to the given reference command)
-
inline const FloatField &referenceEffort() const
The internal effort reference offset (setting this matches the current effort to the given reference command)
-
inline FloatField &velocityLimitMin()
The firmware safety limit for the minimum allowed velocity.
-
inline const FloatField &velocityLimitMin() const
The firmware safety limit for the minimum allowed velocity.
-
inline FloatField &velocityLimitMax()
The firmware safety limit for the maximum allowed velocity.
-
inline const FloatField &velocityLimitMax() const
The firmware safety limit for the maximum allowed velocity.
-
inline FloatField &effortLimitMin()
The firmware safety limit for the minimum allowed effort.
-
inline const FloatField &effortLimitMin() const
The firmware safety limit for the minimum allowed effort.
-
inline FloatField &effortLimitMax()
The firmware safety limit for the maximum allowed effort.
-
inline const FloatField &effortLimitMax() const
The firmware safety limit for the maximum allowed effort.
-
inline HighResAngleField &positionLimitMin()
The firmware safety limit for the minimum allowed position.
-
inline const HighResAngleField &positionLimitMin() const
The firmware safety limit for the minimum allowed position.
-
inline HighResAngleField &positionLimitMax()
The firmware safety limit for the maximum allowed position.
-
inline const HighResAngleField &positionLimitMax() const
The firmware safety limit for the maximum allowed position.
-
inline EnumField<ControlStrategy> &controlStrategy()
How the position, velocity, and effort PID loops are connected in order to control motor PWM.
-
inline const EnumField<ControlStrategy> &controlStrategy() const
How the position, velocity, and effort PID loops are connected in order to control motor PWM.
-
inline EnumField<MstopStrategy> &mstopStrategy()
The motion stop strategy for the actuator.
-
inline const EnumField<MstopStrategy> &mstopStrategy() const
The motion stop strategy for the actuator.
-
inline EnumField<PositionLimitStrategy> &minPositionLimitStrategy()
The position limit strategy (at the minimum position) for the actuator.
-
inline const EnumField<PositionLimitStrategy> &minPositionLimitStrategy() const
The position limit strategy (at the minimum position) for the actuator.
-
inline EnumField<PositionLimitStrategy> &maxPositionLimitStrategy()
The position limit strategy (at the maximum position) for the actuator.
-
inline const EnumField<PositionLimitStrategy> &maxPositionLimitStrategy() const
The position limit strategy (at the maximum position) for the actuator.
-
inline Actuator(HebiCommandRef &internal)
-
class Imu
IMU-specific settings.
-
inline Settings(HebiCommandPtr internal_ptr, HebiCommandRef &internal)
-
class StringField
A message field representable by a std::string.
Public Functions
-
StringField(HebiCommandPtr internal, HebiCommandStringField field)
-
inline explicit operator bool() const
Allows casting to a bool to check if the field has a value without directly calling
has()
.This can be used as in the following (assuming ‘parent’ is a parent message, and this field is called ‘myField’)
Command::StringField& f = parent.myField(); if (f) std::cout << "Field has value: " << f.get() << std::endl; else std::cout << "Field has no value!" << std::endl;
-
bool has() const
True if (and only if) the field has a value.
-
std::string get() const
If the field has a value, returns a copy of that value; otherwise, returns a default.
-
void set(const std::string &value)
Sets the field to a given value.
-
void clear()
Removes any currently set value for this field.
-
StringField(HebiCommandPtr internal, HebiCommandStringField field)
-
enum class ControlStrategy