Class Lookup
Defined in File lookup.hpp
Nested Relationships
Nested Types
Class Documentation
-
class Lookup
Maintains a registry of network-connected modules and returns Group objects to the user.
Only one Lookup object is needed per application.
- Author
Matthew Tesch < matt @ hebirobotics.com >
- Since
18 Feb 2016
Public Functions
-
Lookup()
Creates a Lookup object which can create Module and Group references. Typically, only one Lookup object should exist at a time.
Note that this call invokes a background thread to query the network for modules at regular intervals.
All interfaces besides the loopback interface are used to discover modules.
-
Lookup(const std::vector<std::string> &interfaces)
Creates a Lookup object which can create Module and Group references. Typically, only one Lookup object should exist at a time.
Note that this call invokes a background thread to query the network for modules at regular intervals.
- Parameters:
interfaces – A list of human readable IP addresses for the interfaces to use for discovering modules. For example, {“192.168.1.0”, “10.10.2.0”}. If this list is empty, all interfaces are used (equivalent to Lookup()).
-
~Lookup() noexcept
Destructor frees all resources created by Lookup object, and stops the background query thread.
-
void reset(const std::vector<std::string> &interfaces)
Resets the lookup object to its initial state without destructing and re-constructing the object.
- Parameters:
interfaces – A list of human readable IP addresses for the interfaces to use for discovering modules. For example, {“192.168.1.0”, “10.10.2.0”}. If this list is empty, all interfaces are used.
-
std::shared_ptr<Group> getGroupFromNames(const std::vector<std::string> &families, const std::vector<std::string> &names, int32_t timeout_ms = DEFAULT_TIMEOUT) const
Get a group from modules with the given names and families.
If one of the input vectors is of length one, then that element is assumed to pair with each item in the other input vector.
Blocking call which returns a reference to a Group object with the given parameters. Times out after timeout_msec milliseconds.
- Parameters:
families – A list of families of desired group modules, as viewable in the HEBI GUI. If of length one, this family is paried with each given name.
names – A list of names of desired group modules, as viewable in the HEBI GUI. If of length one, this name is paired with each given family
timeout_ms – Timeout in milliseconds. A value of -1 blocks until a group is found, and a value of 0 returns immediately if no group with that address is currently known by the Lookup class.
- Returns:
A shared_ptr with no reference if no group found in allotted time, or reference to a newly allocated group object corresponding to the given parameters otherwise.
-
std::shared_ptr<Group> getGroupFromMacs(const std::vector<MacAddress> &addresses, int32_t timeout_ms = DEFAULT_TIMEOUT) const
Get a group from modules with the given mac addresses.
Blocking call which returns a reference to a Group object with the given parameters. Times out after timeout_msec milliseconds.
- Parameters:
addresses – List of physical mac addresses for desired group modules.
timeout_ms – Timeout in milliseconds. A value of -1 blocks until a group is found, and a value of 0 returns immediately if no group with that address is currently known by the Lookup class.
- Returns:
A shared_ptr with no reference if no group found in allotted time, or reference to a newly allocated group object corresponding to the given parameters otherwise.
-
std::shared_ptr<Group> getGroupFromFamily(const std::string &family, int32_t timeout_ms = DEFAULT_TIMEOUT) const
Get a group from all known modules with the given family.
Blocking call which returns a reference to a Group object with the given parameters. Times out after timeout_msec milliseconds.
- Parameters:
family – The family of each of the desired group modules.
timeout_ms – Timeout in milliseconds. A value of -1 blocks until a group is found, and a value of 0 returns immediately if no group with that address is currently known by the Lookup class.
- Returns:
A shared_ptr with no reference if no group found in allotted time, or reference to a newly allocated group object corresponding to the given parameters otherwise.
-
std::shared_ptr<Group> getConnectedGroupFromName(const std::string &family, const std::string &name, int32_t timeout_ms = DEFAULT_TIMEOUT) const
Get a group from all modules known to connect to a module with the given name and family.
Blocking call which returns a reference to a Group object with the given parameters. Times out after timeout_msec milliseconds.
- Parameters:
family – The given family of the module, as viewable in the HEBI GUI, to form the group from.
name – The given name of the module, as viewable in the HEBI GUI, to form the group from.
timeout_ms – Timeout in milliseconds. A value of -1 blocks until a group is found, and a value of 0 returns immediately if no group with that address is currently known by the Lookup class.
- Returns:
A shared_ptr with no reference if no group found in allotted time, or reference to a newly allocated group object corresponding to the given parameters otherwise.
-
std::shared_ptr<Group> getConnectedGroupFromMac(const MacAddress &address, int32_t timeout_ms = DEFAULT_TIMEOUT) const
Get a group from all modules known to connect to a module with the given mac address.
Blocking call which returns a reference to a Group object with the given parameters. Times out after timeout_msec milliseconds.
- Parameters:
address – Physical mac address of the module to form the group from.
timeout_ms – Timeout in milliseconds. A value of -1 blocks until a group is found, and a value of 0 returns immediately if no group with that address is currently known by the Lookup class.
- Returns:
A shared_ptr with no reference if no group found in allotted time, or reference to a newly allocated group object corresponding to the given parameters otherwise.
-
float getInitialGroupFeedbackFrequencyHz()
Gets the default feedback frequency value for groups created from this lookup.
Defaults to 100 Hz.
See Group documentation for detailed usage, and docs.hebi.us for more information on feedback requests.
-
void setInitialGroupFeedbackFrequencyHz(float frequency)
Sets the default feedback frequency value for groups created from this lookup.
- Parameters:
frequency – The frequency, in Hz, that newly-created groups will request feedback at.
-
int32_t getInitialGroupCommandLifetimeMs()
Gets the default command lifetime value for groups created from this lookup.
Defaults to 250 ms.
See Group documentation for detailed usage, and docs.hebi.us for more information on Command Lifetime.
-
void setInitialGroupCommandLifetimeMs(int32_t ms)
Sets the default command lifetime value for groups created from this lookup.
- Parameters:
ms – The number of milliseconds that newly-created groups will use as their command lifetime when sending out commands.
-
double getLookupFrequencyHz() const
Gets the rate [Hz] at which “discovery” packets are broadcast.
Defaults to 5 Hz.
-
bool setLookupFrequencyHz(double frequency)
Sets the lookup rate [Hz].
- Parameters:
frequency – The rate at which “discovery” packets get broadcast on the network to search for modules.
- Returns:
true on success, false on failure (e.g., invalid frequency)
-
class EntryList