Class Command

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 calling if(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”

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.

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.

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!

Command(Command &&other)

Move constructor (necessary for containment in STL template classes)

inline Io &io()

Any available digital or analog output pins on the device.

inline const Io &io() const

Any available digital or analog output pins on the device.

inline Settings &settings()

Module settings that are typically changed at a slower rate.

inline const Settings &settings() const

Module settings that are typically changed at a slower rate.

inline Actuator &actuator()

Actuator-specific commands.

inline const Actuator &actuator() const

Actuator-specific commands.

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.

inline FlagField &reset()

Restart the module.

inline const FlagField &reset() const

Restart the module.

inline FlagField &boot()

Boot the module from bootloader into application.

inline const FlagField &boot() const

Boot the module from bootloader into application.

inline FlagField &stopBoot()

Stop the module from automatically booting into application.

inline const FlagField &stopBoot() const

Stop the module from automatically booting into application.

inline FlagField &clearLog()

Clears the log message on the module.

inline const FlagField &clearLog() const

Clears the log message on the module.

inline LedField &led()

The module’s LED.

inline const LedField &led() const

The module’s LED.

Command &operator=(Command &&other) = delete

Disable copy constructor/assignment operators

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.

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.

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 T get() const

If the field has a value, returns that value; otherwise, returns a default.

inline void set(T _value)

Sets the field to a given value.

inline void clear()

Removes any currently set value for this 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).

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.

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.

class Io

Any available digital or analog output pins on the device.

Public Functions

inline Io(HebiCommandPtr internal, HebiCommandRef &internal_ref)
inline IoBank &a()

I/O pin bank a (pins 1-8 available)

inline const IoBank &a() const

I/O pin bank a (pins 1-8 available)

inline IoBank &b()

I/O pin bank b (pins 1-8 available)

inline const IoBank &b() const

I/O pin bank b (pins 1-8 available)

inline IoBank &c()

I/O pin bank c (pins 1-8 available)

inline const IoBank &c() const

I/O pin bank c (pins 1-8 available)

inline IoBank &d()

I/O pin bank d (pins 1-8 available)

inline const IoBank &d() const

I/O pin bank d (pins 1-8 available)

inline IoBank &e()

I/O pin bank e (pins 1-8 available)

inline const IoBank &e() const

I/O pin bank e (pins 1-8 available)

inline IoBank &f()

I/O pin bank f (pins 1-8 available)

inline const IoBank &f() const

I/O pin bank f (pins 1-8 available)

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.

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.

IpAddress get() const

If the field has a value, returns that value; otherwise, returns 0.0.0.0.

void set(const IpAddress &value)

Sets the field to a given value.

void clear()

Removes any currently set value for this 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).

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.

class Settings

Module settings that are typically changed at a slower rate.

Public Functions

inline Settings(HebiCommandPtr internal_ptr, HebiCommandRef &internal)
inline Actuator &actuator()

Actuator-specific settings, such as controller gains.

inline const Actuator &actuator() const

Actuator-specific settings, such as controller gains.

inline Imu &imu()

IMU-specific settings.

inline const Imu &imu() const

IMU-specific settings.

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.

inline FlagField &saveCurrentSettings()

Indicates if the module should save the current values of all of its settings.

inline const FlagField &saveCurrentSettings() const

Indicates if the module should save the current values of all of its settings.

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.

class Imu

IMU-specific settings.

Public Functions

inline Imu(HebiCommandRef &internal)
inline BoolField &accelIncludesGravity()

Whether to include acceleration due to gravity in acceleration feedback.

inline const BoolField &accelIncludesGravity() const

Whether to include acceleration due to gravity in acceleration feedback.

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.