rosidl icon indicating copy to clipboard operation
rosidl copied to clipboard

Escape default arrays and sequences the same other default values

Open jacobperron opened this issue 3 years ago • 6 comments

Fixes #610

jacobperron avatar Sep 30 '21 01:09 jacobperron

As a regression test, I've added a new field to one of the test messages: https://github.com/ros2/test_interface_files/pull/16

jacobperron avatar Sep 30 '21 01:09 jacobperron

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

jacobperron avatar Sep 30 '21 01:09 jacobperron

Rpr fails because https://github.com/ament/ament_cmake/pull/352 has not been released.

jacobperron avatar Sep 30 '21 01:09 jacobperron

This is interesting. I can't predict if it will pass the test_communication tests. I recommend adding another test to test_interface_files with "ハローワールド" to see what it does when given a string with characters outside the latin-1 character set.

https://github.com/ros2/test_interface_files/blob/ea4d4f33eca97f37b4294e6ab012fa0f216de609/msg/WStrings.msg#L2-L4

IIUC Hellö wörld!" in that .msg file is encoded as the UTF-8 bytes b'Hell\xc3\xb6 w\xc3\xb6rld!'. When read as latin-1 the string in Python would be very different from the original.

>>> b'Hell\xc3\xb6 w\xc3\xb6rld!'.decode('latin-1')
'Hellö wörld!'

When re-encoded as latin-1 that should output the original bytes, but there's some more weirdness when the generators read the idl files.

https://github.com/ros2/rosidl/blob/36ed120f43daeaab31fd9ba2bf8dfb58db05091d/rosidl_parser/rosidl_parser/parser.py#L660

sloretz avatar Sep 30 '21 01:09 sloretz

IIUC Hellö wörld!" in that .msg file is encoded as the UTF-8 bytes b'Hell\xc3\xb6 w\xc3\xb6rld!'. When read as latin-1 the string in Python would be very different from the original.

In fact there were test failures related to this that I missed locally: https://ci.ros2.org/job/ci_linux/15332/testReport/junit/rosidl_generator_py.test/test_interfaces/test_wstrings/

jacobperron avatar Oct 05 '21 01:10 jacobperron

I think the issue was due to a difference in how we handled default values of arrays and sequences compared with other default values. See 8253770, which applies similar logic to array/sequence defaults as we do with other defaults, e.g.

https://github.com/ros2/rosidl/blob/36ed120f43daeaab31fd9ba2bf8dfb58db05091d/rosidl_adapter/rosidl_adapter/msg/init.py#L78-L79

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

jacobperron avatar Oct 14 '21 20:10 jacobperron