Skip to content

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

Open
@sebastian-freitag

Description

@sebastian-freitag

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions