44 std::array<bool, 9> has_state_bits_;
45 std::array<double, 9> state_values_;
50 UserState(
double v1,
double v2,
double v3,
double v4,
double v5,
double v6,
double v7,
51 double v8,
double v9) :
52 state_values_({v1, v2, v3, v4, v5, v6, v7, v8, v9}) {
54 has_state_bits_.fill(
true);
64 return (number >= 1 && number <= 9) ? (has_state_bits_[number - 1]) :
false;
74 return (number >= 1 && number <= 9) ? (state_values_[number - 1]) : 0;
84 if (number < 1 || number > 9)
86 has_state_bits_[number - 1] =
true;
87 state_values_[number - 1] = value;
96 if (number < 1 || number > 9)
98 has_state_bits_[number - 1] =
false;
113 HebiGroupPtr internal_;
118 const size_t number_of_modules_;
123 std::mutex handler_lock_;
129 std::vector<GroupFeedbackHandler> handlers_;
131 #ifndef DOXYGEN_OMIT_INTERNAL 136 friend void callbackWrapper(HebiGroupFeedbackPtr group_feedback,
void* user_data);
137 #endif // DOXYGEN_OMIT_INTERNAL 143 void callAttachedHandlers(HebiGroupFeedbackPtr group_feedback);
152 #ifndef DOXYGEN_OMIT_INTERNAL 158 Group(HebiGroupPtr group,
float initial_feedback_frequency = 0.0f, int32_t initial_command_lifetime = 0);
159 #endif // DOXYGEN_OMIT_INTERNAL 287 std::
string startLog(const std::
string& dir) const;
299 std::
string startLog(const std::
string& dir, const std::
string& file) const;
void addFeedbackHandler(GroupFeedbackHandler handler)
Adds a handler function to be called by the internal feedback request thread.
Definition: group.cpp:163
std::shared_ptr< LogFile > stopLog() const
Stops any active log.
Definition: group.cpp:131
A list of Feedback objects that can be received from a Group of modules; the size() must match the nu...
Definition: group_feedback.hpp:18
void clearFeedbackHandlers()
Removes all feedback handlers presently added.
Definition: group.cpp:170
Represents a group of physical HEBI modules, and allows Command, Feedback, and Info objects to be sen...
Definition: group.hpp:106
A list of Info objects that can be received from a Group of modules; the size() must match the number...
Definition: group_info.hpp:18
void clearValue(size_t number)
Clears the specific value set in the UserState.
Definition: group.hpp:95
~Group() noexcept
Destructor cleans up group.
Definition: group.cpp:42
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.
Definition: group.cpp:65
InfoExtraFields
Definition: group.hpp:33
static const int32_t DEFAULT_TIMEOUT_MS
The default timeout for any send-with-acknowledgement or request operation is 500 ms.
Definition: group.hpp:150
bool sendCommand(const GroupCommand &group_command)
Send a command to the given group without requesting an acknowledgement.
Definition: group.cpp:58
bool setCommandLifetimeMs(int32_t ms)
Sets the command lifetime for the modules in this group.
Definition: group.cpp:50
bool requestInfoExtra(GroupInfo &info, InfoExtraFields extra_fields, int32_t timeout_ms=DEFAULT_TIMEOUT_MS)
Request info from the group, and store it in the passed-in info object. Include extra fields.
Definition: group.cpp:88
#define HEBI_DISABLE_COPY_MOVE(Class)
Definition: util.hpp:6
Definition: log_file.hpp:11
Definition: mobile_io.hpp:24
static std::shared_ptr< Group > createImitation(size_t size)
Creates an imitation group of provided size.
Definition: group.cpp:38
int32_t getCommandLifetimeMs() const
Returns the command lifetime for the modules in this group.
Definition: group.cpp:54
bool hasValue(size_t number) const
Does the UserState have the specific value set?
Definition: group.hpp:63
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 recei...
Definition: group.cpp:74
std::string startLog(const std::string &dir) const
Starts log (stopping any active log).
Definition: group.cpp:95
size_t size() const
Returns the number of modules in the group.
Definition: group.cpp:48
float getFeedbackFrequencyHz() const
Gets the frequency of the internal feedback request + callback thread.
Definition: group.cpp:161
std::function< void(const GroupFeedback &)> GroupFeedbackHandler
Definition of a callback function for GroupFeedback returned from a Group of modules.
Definition: group.hpp:31
A list of Command objects appropriate for sending to a Group of modules; the size() must match the nu...
Definition: group_command.hpp:19
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.
Definition: group.cpp:81
UserState(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8, double v9)
Definition: group.hpp:50
double getValue(size_t number) const
Get the specific UserState value.
Definition: group.hpp:73
void setValue(size_t number, double value)
Set the specific value in the UserState.
Definition: group.hpp:83
bool logUserState(const UserState &state) const
Adds a message directly to the log file without sending anything to the group. The message can have 9...
Definition: group.cpp:140
bool setFeedbackFrequencyHz(float frequency)
Sets the frequency of the internal feedback request + callback thread.
Definition: group.cpp:157
bool sendFeedbackRequest()
Requests feedback from the group.
Definition: group.cpp:72