Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
hebi::Lookup Class Referencefinal

Maintains a registry of network-connected modules and returns Group objects to the user. More...

#include <lookup.hpp>

Classes

class  EntryList
 

Public Member Functions

std::shared_ptr< GroupgetConnectedGroupFromMac (const MacAddress &address, int32_t timeout_ms=DEFAULT_TIMEOUT)
 Get a group from all modules known to connect to a module with the given mac address. More...
 
std::shared_ptr< GroupgetConnectedGroupFromName (const std::string &family, const std::string &name, int32_t timeout_ms=DEFAULT_TIMEOUT)
 Get a group from all modules known to connect to a module with the given name and family. More...
 
std::shared_ptr< EntryListgetEntryList ()
 
std::shared_ptr< GroupgetGroupFromFamily (const std::string &family, int32_t timeout_ms=DEFAULT_TIMEOUT)
 Get a group from all known modules with the given family. More...
 
std::shared_ptr< GroupgetGroupFromMacs (const std::vector< MacAddress > &addresses, int32_t timeout_ms=DEFAULT_TIMEOUT)
 Get a group from modules with the given mac addresses. More...
 
std::shared_ptr< GroupgetGroupFromNames (const std::vector< std::string > &families, const std::vector< std::string > &names, int32_t timeout_ms=DEFAULT_TIMEOUT)
 Get a group from modules with the given names and families. More...
 
int32_t getInitialGroupCommandLifetimeMs ()
 Gets the default command lifetime value for groups created from this lookup. More...
 
float getInitialGroupFeedbackFrequencyHz ()
 Gets the default feedback frequency value for groups created from this lookup. More...
 
double getLookupFrequencyHz () const
 Gets the rate [Hz] at which "discovery" packets are broadcast. More...
 
 Lookup ()
 Creates a Lookup object which can create Module and Group references. Typically, only one Lookup object should exist at a time. More...
 
void setInitialGroupCommandLifetimeMs (int32_t ms)
 Sets the default command lifetime value for groups created from this lookup. More...
 
void setInitialGroupFeedbackFrequencyHz (float frequency)
 Sets the default feedback frequency value for groups created from this lookup. More...
 
bool setLookupFrequencyHz (double frequency)
 Sets the lookup rate [Hz]. More...
 
 ~Lookup () noexcept
 Destructor frees all resources created by Lookup object, and stops the background query thread. More...
 

Private Attributes

int32_t initial_group_command_lifetime_ {250}
 
float initial_group_feedback_frequency_ {100.0f}
 
HebiLookupPtr lookup_
 

Static Private Attributes

static const int32_t DEFAULT_TIMEOUT = 500
 

Detailed Description

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

Definition at line 24 of file lookup.hpp.

Constructor & Destructor Documentation

hebi::Lookup::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.

Definition at line 7 of file lookup.cpp.

hebi::Lookup::~Lookup ( )
noexcept

Destructor frees all resources created by Lookup object, and stops the background query thread.

Definition at line 9 of file lookup.cpp.

Member Function Documentation

std::shared_ptr< Group > hebi::Lookup::getConnectedGroupFromMac ( const MacAddress address,
int32_t  timeout_ms = DEFAULT_TIMEOUT 
)

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
addressPhysical mac address of the module to form the group from.
timeout_msTimeout 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.

Definition at line 60 of file lookup.cpp.

std::shared_ptr< Group > hebi::Lookup::getConnectedGroupFromName ( const std::string &  family,
const std::string &  name,
int32_t  timeout_ms = DEFAULT_TIMEOUT 
)

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
familyThe given family of the module, as viewable in the HEBI GUI, to form the group from.
nameThe given name of the module, as viewable in the HEBI GUI, to form the group from.
timeout_msTimeout 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.

Definition at line 51 of file lookup.cpp.

std::shared_ptr< Lookup::EntryList > hebi::Lookup::getEntryList ( )

Definition at line 148 of file lookup.cpp.

std::shared_ptr< Group > hebi::Lookup::getGroupFromFamily ( const std::string &  family,
int32_t  timeout_ms = DEFAULT_TIMEOUT 
)

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
familyThe family of each of the desired group modules.
timeout_msTimeout 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.

Definition at line 43 of file lookup.cpp.

std::shared_ptr< Group > hebi::Lookup::getGroupFromMacs ( const std::vector< MacAddress > &  addresses,
int32_t  timeout_ms = DEFAULT_TIMEOUT 
)

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
addressesList of physical mac addresses for desired group modules.
timeout_msTimeout 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.

Definition at line 31 of file lookup.cpp.

std::shared_ptr< Group > hebi::Lookup::getGroupFromNames ( const std::vector< std::string > &  families,
const std::vector< std::string > &  names,
int32_t  timeout_ms = DEFAULT_TIMEOUT 
)

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
familiesA 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.
namesA 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_msTimeout 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.

Definition at line 11 of file lookup.cpp.

int32_t hebi::Lookup::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.

Definition at line 72 of file lookup.cpp.

float hebi::Lookup::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.

Definition at line 68 of file lookup.cpp.

double hebi::Lookup::getLookupFrequencyHz ( ) const

Gets the rate [Hz] at which "discovery" packets are broadcast.

Defaults to 5 Hz.

Definition at line 76 of file lookup.cpp.

void hebi::Lookup::setInitialGroupCommandLifetimeMs ( int32_t  ms)

Sets the default command lifetime value for groups created from this lookup.

Parameters
msThe number of milliseconds that newly-created groups will use as their command lifetime when sending out commands.

Definition at line 74 of file lookup.cpp.

void hebi::Lookup::setInitialGroupFeedbackFrequencyHz ( float  frequency)

Sets the default feedback frequency value for groups created from this lookup.

Parameters
frequencyThe frequency, in Hz, that newly-created groups will request feedback at.

Definition at line 70 of file lookup.cpp.

bool hebi::Lookup::setLookupFrequencyHz ( double  frequency)

Sets the lookup rate [Hz].

Parameters
frequencyThe 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)

Definition at line 78 of file lookup.cpp.

Member Data Documentation

const int32_t hebi::Lookup::DEFAULT_TIMEOUT = 500
staticprivate

Definition at line 26 of file lookup.hpp.

int32_t hebi::Lookup::initial_group_command_lifetime_ {250}
private

Default value of command lifetime used when creating new groups.

Definition at line 41 of file lookup.hpp.

float hebi::Lookup::initial_group_feedback_frequency_ {100.0f}
private

Default value of feedback frequency used when creating new groups.

Definition at line 36 of file lookup.hpp.

HebiLookupPtr hebi::Lookup::lookup_
private

Definition at line 31 of file lookup.hpp.


The documentation for this class was generated from the following files:


hebi_cpp_api_ros
Author(s): Chris Bollinger , Matthew Tesch
autogenerated on Thu May 28 2020 03:14:45