Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with protobuf generation when there is a multiline comments in the msg file #11

Open
sebastian-freitag opened this issue Mar 15, 2022 · 1 comment

Comments

@sebastian-freitag
Copy link

ROS2 Galactic.

Simple Example of the Bug.

Consider the file UUID.msg, identical with ros2/unique_identifier_msgs/msg/UUID.msg:

# A universally unique identifier (UUID).
#
#  http://en.wikipedia.org/wiki/Universally_unique_identifier
#  http://tools.ietf.org/html/rfc4122.html

uint8[16] uuid

Consider the file UUID.idl, generated by ROS2:

// generated from rosidl_adapter/resource/msg.idl.em
// with input from unique_identifier_msgs/msg/UUID.msg
// generated code does not contain a copyright notice


module unique_identifier_msgs {
  module msg {
    typedef uint8 uint8__16[16];
    @verbatim (language="comment", text=
      " A universally unique identifier (UUID)." "\n"
      "" "\n"
      "  http://en.wikipedia.org/wiki/Universally_unique_identifier" "\n"
      "  http://tools.ietf.org/html/rfc4122.html")
    struct UUID {
      uint8__16 uuid;
    };
  };
};

Consider the file UUID.proto, this is the file generated by rosidl_typesupport_protobuf/rosidl_adapter_proto/bin/rosidl_adapter_proto:

// generated from rosidl_adapter_proto/resource/idl.proto.em
// with input from unique_identifier_msgs:msg/UUID.idl
// generated code does not contain a copyright notice

syntax = "proto3";

package unique_identifier_msgs.msg.pb;

// A universally unique identifier (UUID).

 http://en.wikipedia.org/wiki/Universally_unique_identifier
 http://tools.ietf.org/html/rfc4122.html
message UUID
{

 bytes uuid = 293563397;
}

This is wrong and protoc will not compile it.
Lines 9-12 should instead be this:

// A universally unique identifier (UUID).
//
//  http://en.wikipedia.org/wiki/Universally_unique_identifier
//  http://tools.ietf.org/html/rfc4122.html

I think the problem is with this expression inside msg.proto.em: comment = "//" + re.sub(r"\\n", "\n//", annotation.value["text"]). However, I do not know why this ever worked, maybe re changed or an issue about different python versions. On my environment, if I change this line to comment = "//" + re.sub(r"\n", "\n//", annotation.value["text"]), then generation works OK.

@r7vme
Copy link

r7vme commented Mar 25, 2022

@sebastian-freitag-pylot we were also hit by this bug. It also was not clear for me if smth changed in re behaviors or it never worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants