Skip to content

Commit

Permalink
feat(tier4_autoware_utils): add generateUUID to uuid helper (#2902)
Browse files Browse the repository at this point in the history
* feat(tier4_autoware_utils): add generateUUID to uuid helper

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): add missed include

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

---------

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota authored Feb 18, 2023
1 parent fd60ca4 commit 5636b55
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@

#include <unique_identifier_msgs/msg/uuid.hpp>

#include <random>
#include <string>

namespace tier4_autoware_utils
{
inline unique_identifier_msgs::msg::UUID generateUUID()
{
// Generate random number
unique_identifier_msgs::msg::UUID uuid;
std::mt19937 gen(std::random_device{}());
std::independent_bits_engine<std::mt19937, 8, uint8_t> bit_eng(gen);
std::generate(uuid.uuid.begin(), uuid.uuid.end(), bit_eng);

return uuid;
}
inline std::string toHexString(const unique_identifier_msgs::msg::UUID & id)
{
std::stringstream ss;
Expand Down

0 comments on commit 5636b55

Please sign in to comment.