|
HEBI C++ API
1.0.0
|
Represents a group of physical HEBI modules, and allows Command, Feedback, and Info objects to be sent to and recieved from the hardware. More...
#include <group.hpp>
Public Member Functions | |
| ~Group () noexcept | |
| Destructor cleans up group. More... | |
| int | size () |
| Returns the number of modules in the group. More... | |
| bool | setCommandLifetimeMs (int32_t ms) |
| Sets the command lifetime for the modules in this group. More... | |
| bool | sendCommand (const GroupCommand &group_command) |
| Send a command to the given group without requesting an acknowledgement. More... | |
| bool | sendCommandWithAcknowledgement (const GroupCommand &group_command, int32_t timeout_ms=DEFAULT_TIMEOUT_MS) |
| Send a command to the given group, requesting an acknowledgement of transmission to be sent back. More... | |
| bool | sendFeedbackRequest () |
| Requests feedback from the group. More... | |
| bool | getNextFeedback (GroupFeedback &feedback, int32_t timeout_ms=DEFAULT_TIMEOUT_MS) |
| Returns the most recently stored feedback from a sent feedback request, or returns the next one received (up to the requested timeout). More... | |
| bool | requestInfo (GroupInfo &info, int32_t timeout_ms=DEFAULT_TIMEOUT_MS) |
| Request info from the group, and store it in the passed-in info object. More... | |
| bool | setFeedbackFrequencyHz (float frequency) |
| Sets the frequency of the internal feedback request + callback thread. More... | |
| float | getFeedbackFrequencyHz () |
| Gets the frequency of the internal feedback request + callback thread. More... | |
| void | addFeedbackHandler (GroupFeedbackHandler handler) |
| Adds a handler function to be called by the internal feedback request thread. More... | |
| void | clearFeedbackHandlers () |
| Removes all feedback handlers presently added. More... | |
Static Public Member Functions | |
| static std::shared_ptr< Group > | createImitation (size_t size) |
| Creates an imitation group of provided size. More... | |
Static Public Attributes | |
| static const int32_t | DEFAULT_TIMEOUT_MS = 500 |
| The default timeout for any send-with-acknowledgement or request operation is 500 ms. More... | |
Represents a group of physical HEBI modules, and allows Command, Feedback, and Info objects to be sent to and recieved from the hardware.
|
noexcept |
Destructor cleans up group.
| int hebi::Group::size | ( | ) |
Returns the number of modules in the group.
| bool hebi::Group::setCommandLifetimeMs | ( | int32_t | ms | ) |
Sets the command lifetime for the modules in this group.
This parameter defines how long a module will execute a command set point sent to it. Note the commands from other systems/applications are ignored during this time. A value of '0' indicates commands last forever, and there is no lockout behavior.
See docs.hebi.us for more information.
| bool hebi::Group::sendCommand | ( | const GroupCommand & | group_command | ) |
Send a command to the given group without requesting an acknowledgement.
Appropriate for high-frequency applications.
| group_command | The GroupCommand object containing information to be sent to the group. |
| bool hebi::Group::sendCommandWithAcknowledgement | ( | const GroupCommand & | group_command, |
| int32_t | timeout_ms = DEFAULT_TIMEOUT_MS |
||
| ) |
Send a command to the given group, requesting an acknowledgement of transmission to be sent back.
| group_command | The GroupCommand object containing information to be sent to the group. |
| timeout_ms | Indicates how many milliseconds to wait for a response after sending a packet. For typical networks, '15' ms is a value that can be reasonably expected to encompass the time required for a round-trip transmission. |
Note: A non-true return does not indicate a specific failure, and may result from an error while sending or simply a timeout/dropped response packet after a successful transmission.
| bool hebi::Group::sendFeedbackRequest | ( | ) |
Requests feedback from the group.
Sends a background request to the modules in the group; if/when all modules return feedback, any associated handler functions are called. This returned feedback is also stored to be returned by the next call to getNextFeedback (any previously returned data is discarded).
true if feedback was request was successfully sent, otherwise false on failure (i.e., connection error). | bool hebi::Group::getNextFeedback | ( | GroupFeedback & | feedback, |
| int32_t | timeout_ms = DEFAULT_TIMEOUT_MS |
||
| ) |
Returns the most recently stored feedback from a sent feedback request, or returns the next one received (up to the requested timeout).
Note that a feedback request can be sent either with the sendFeedbackRequest function, or by setting a background feedback frequency with setFeedbackFrequencyHz.
Warning: other data in the provided 'Feedback' object is erased!
| feedback | On success, the group feedback read from the group are written into this structure. |
| timeout_ms | Indicates how many milliseconds to wait for feedback. For typical networks, '15' ms is a value that can be reasonably expected to allow for a round trip transmission after the last 'send feedback request' call. |
true if feedback was returned, otherwise false on failure (i.e., connection error or timeout waiting for response). | bool hebi::Group::requestInfo | ( | GroupInfo & | info, |
| int32_t | timeout_ms = DEFAULT_TIMEOUT_MS |
||
| ) |
Request info from the group, and store it in the passed-in info object.
| bool hebi::Group::setFeedbackFrequencyHz | ( | float | frequency | ) |
Sets the frequency of the internal feedback request + callback thread.
true if the frequency successfully was set, or false if the parameter was outside the accepted range (less than zero or faster than supported maximum). | float hebi::Group::getFeedbackFrequencyHz | ( | ) |
Gets the frequency of the internal feedback request + callback thread.
| void hebi::Group::addFeedbackHandler | ( | GroupFeedbackHandler | handler | ) |
Adds a handler function to be called by the internal feedback request thread.
| void hebi::Group::clearFeedbackHandlers | ( | ) |
Removes all feedback handlers presently added.
|
static |
Creates an imitation group of provided size.
| size | the number of modules in the group |
|
static |
The default timeout for any send-with-acknowledgement or request operation is 500 ms.