rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

Fix the GoalUUID to_string representation

Open nwn opened this issue 3 years ago • 2 comments

Changes the string representation of rclcpp_action::GoalUUIDs to match the canonical format described in RFC 4122. (The current representation doesn't contain hyphens and omits the leading zero in the hex of a byte.)

nwn avatar Aug 19 '22 12:08 nwn

I'm not necessarily opposed to changing it, but I would like to know the motivation (other than just conforming to the RFC). There are possible backwards-compatibility things to consider here.

clalancette avatar Aug 19 '22 18:08 clalancette

@fujitatomoya I agree, we should use a consistent format across client libraries. Unfortunately, rclpy currently doesn't format goal IDs well either. For example, the rclpy action server prints them as arrays of integers:

[DEBUG] [1661282923.515954250] [minimal_action_server]: New goal request with ID: [231  15 208   8 188 196  68  43 129  63  56 102  30 126  48 197]

So it would be good to start standardizing this output.

@clalancette The issues with the current string representation aren't just aesthetic or pedantic. Omitting the leading zero in a byte is actually ambiguous. For example, the two UUIDs 01100000-0000-0000-0000-000000000000 and 11000000-0000-0000-0000-000000000000 will both be converted to the string 11000000000000000 in the current representation. If users are comparing the string values of these UUIDs or storing them in a hash table, this would cause collisions.

nwn avatar Aug 23 '22 20:08 nwn

@fujitatomoya @clalancette Are there any further concerns about this or action required to get this merged?

nwn avatar Feb 08 '23 23:02 nwn

Just FYI, I see https://github.com/ros2/geometry2 uses this method, but all issued for debug print.

fujitatomoya avatar Feb 09 '23 17:02 fujitatomoya

I've rebased this onto the latest, and I've also done a bit more cleanup in here. In particular, I made the whole thing a little more efficient by using .resize instead of .reserve on the string, and by adding in the dashes in the main loop (rather than adding them in separately).

I also did a quick look around the code base and came to the same conclusion that Tomoya did; the only uses seem to be in the tests here and in debug messages in tf2_ros. So I think this is good to go, I'm going to go ahead and approve this and run CI.

That said, I did some work on this, so I'd appreciate another look from @fujitatomoya before I go ahead and merge.

clalancette avatar Mar 01 '23 20:03 clalancette

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

clalancette avatar Mar 01 '23 20:03 clalancette

CI is green with this, so going ahead and merging. Thanks for the contribution!

clalancette avatar Mar 02 '23 12:03 clalancette