Namespaces | Functions
unique_id Namespace Reference

C++ namespace for unique_id helper functions. More...

Namespaces

 impl
 C++ namespace for private implementation details.
 

Functions

static boost::uuids::uuid fromHexString (std::string const &str)
 Generate UUID from canonical hex string. More...
 
static boost::uuids::uuid fromMsg (uuid_msgs::UniqueID const &msg)
 Create UUID object from UniqueID message. More...
 
static boost::uuids::uuid fromRandom (void)
 Generate a random UUID object. More...
 
static boost::uuids::uuid fromTime (ros::Time timestamp, uint64_t hw_addr)
 Generate a Time Based UUID object. Users are recommended to seed the random number generator using srand from the calling application to generate the clock_id. More...
 
static boost::uuids::uuid fromURL (std::string const &url)
 Generate UUID from Uniform Resource Identifier. More...
 
static std::string toHexString (boost::uuids::uuid const &uu)
 Get the canonical string representation for a boost UUID. More...
 
static std::string toHexString (uuid_msgs::UniqueID const &msg)
 Get the canonical string representation for a UniqueID message. More...
 
static uuid_msgs::UniqueID toMsg (boost::uuids::uuid const &uu)
 Create a UniqueID message from a UUID object. More...
 

Detailed Description

C++ namespace for unique_id helper functions.

Various ROS components use universally unique identifiers. This header provides functions for working with a common uuid_msgs/UniqueID message, and the boost uuid class.

Programmers are free to create UUID objects using any approved RFC 4122 method. The boost uuid interface supports them all.

Functions in this namespace provide simple APIs, not requiring detailed knowledge of RFC 4122 or the boost uuid interface. ROS applications are likely to need either a random or a name-based UUID.

Function Documentation

◆ fromHexString()

static boost::uuids::uuid unique_id::fromHexString ( std::string const &  str)
inlinestatic

Generate UUID from canonical hex string.

Parameters
strstring containing canonical hex representation
Returns
corresponding boost::uuids::uuid object.
Note
This is not a general service for generating a UUID from an arbitrary character string. The fromURL() function will do that for any Uniform Resource Identifier.

The canonical hex string is a human-readable representation of a correctly-formatted sixteen-byte UUID. In addition to the dashes, it should contain exactly 32 hexadecimal digits. The str can be any accepted by the boost uuid string generator, but that is not well-defined. The format produced by toHexString() works reliably: "01234567-89ab-cdef-0123-456789abcdef".

Warning
Strings not accepted by boost may produce undefined results: perhaps throwing a std::runtime_error exception, or silently ignoring parts of the string.

Definition at line 125 of file unique_id.h.

◆ fromMsg()

static boost::uuids::uuid unique_id::fromMsg ( uuid_msgs::UniqueID const &  msg)
inlinestatic

Create UUID object from UniqueID message.

Parameters
msguuid_msgs/UniqueID message.
Returns
boost::uuids::uuid object.

Definition at line 85 of file unique_id.h.

◆ fromRandom()

static boost::uuids::uuid unique_id::fromRandom ( void  )
inlinestatic

Generate a random UUID object.

Returns
type 4 boost::uuids::uuid object.

Different calls to this function at any time or place will almost certainly generate different UUIDs. The method used is RFC 4122 variant 4.

Definition at line 100 of file unique_id.h.

◆ fromTime()

static boost::uuids::uuid unique_id::fromTime ( ros::Time  timestamp,
uint64_t  hw_addr 
)
inlinestatic

Generate a Time Based UUID object. Users are recommended to seed the random number generator using srand from the calling application to generate the clock_id.

Parameters
timestampThe ros::Time timestamp for UUID generation
hw_addrA 48-bit (6 octets) network address assigned to the 48 LSBs
Returns
type 1 boost::uuids::uuid object.

Different calls to this function at any time or place will almost certainly generate different UUIDs. The method used is RFC 4122 version 1.

Definition at line 167 of file unique_id.h.

◆ fromURL()

static boost::uuids::uuid unique_id::fromURL ( std::string const &  url)
inlinestatic

Generate UUID from Uniform Resource Identifier.

Parameters
urlURL for identifier creation.
Returns
type 5 boost::uuids::uuid object.

Matching url strings must yield the same UUID. Different url strings will almost certainly generate different UUIDs. The method used is RFC 4122 variant 5, computing the SHA-1 hash of the url.

For any given url, this function returns the same UUID as the corresponding Python unique_id.fromURL() function.

For example, Open Street Map identifiers are encoded like this, with decimal representations of the integer OSM node, way, or relation identifiers appended to the URL:

  • fromURL("http://openstreetmap.org/node/123456789")
  • fromURL("http://openstreetmap.org/way/6543210")
  • fromURL("http://openstreetmap.org/relation/999999")

Definition at line 151 of file unique_id.h.

◆ toHexString() [1/2]

static std::string unique_id::toHexString ( boost::uuids::uuid const &  uu)
inlinestatic

Get the canonical string representation for a boost UUID.

Parameters
uuboost::uuids::uuid object.
Returns
canonical UUID hex string: "01234567-89ab-cdef-0123-456789abcdef".

A boost::uuids::uuid object yields the same representation via its << operator or to_string() function.

Definition at line 192 of file unique_id.h.

◆ toHexString() [2/2]

static std::string unique_id::toHexString ( uuid_msgs::UniqueID const &  msg)
inlinestatic

Get the canonical string representation for a UniqueID message.

Parameters
msguuid_msgs/UniqueID message.
Returns
canonical UUID hex string: "01234567-89ab-cdef-0123-456789abcdef".

Definition at line 202 of file unique_id.h.

◆ toMsg()

static uuid_msgs::UniqueID unique_id::toMsg ( boost::uuids::uuid const &  uu)
inlinestatic

Create a UniqueID message from a UUID object.

Parameters
uuboost::uuids::uuid object.
Returns
uuid_msgs/UniqueID message.

Definition at line 177 of file unique_id.h.



unique_id
Author(s): Jack O'Quin
autogenerated on Mon Mar 6 2023 03:18:07