Skip to content

proto <> ros functionality#611

Draft
mvukov wants to merge 22 commits into
mainfrom
feature/proto_to_msg
Draft

proto <> ros functionality#611
mvukov wants to merge 22 commits into
mainfrom
feature/proto_to_msg

Conversation

@mvukov
Copy link
Copy Markdown
Owner

@mvukov mvukov commented Feb 28, 2026

cf. #500 and #605.

Given a, let's say, "public" API in protos (that you could use in backend), this PR allows you to have equivalent msg type to use them in ROS. Plus, adds converters.

Adds support for:

  1. Generating ROS msg files from proto files. Limitation is 1 msg per proto file. This way Bazel knows that for 1 proto file there is going to be one msg file. This is also a very good practice anyway.
  2. Generating ROS <> proto converter functionality.

This is a Bazel-native solution that (again) leverages Bazel aspects. In other words, Bazel takes care that code generation is properly done through the dependency graph. TBH, didn't look into proto2ros closely, but I saw possible issues in dependency propagation when working with Bazel.

The code is messy, brother Claude and I hacked this up in a short amount of time.

TODOs:

  • Add support for enums.
  • Add "native" conversions -- e.g. proto timestamp <> ROS timestamp. This will likely require a small runtime library.
  • Ignore deprecated proto fields for msg code generation. What about deprecated messages? Can code ROS code generation handle empty files?
  • Get the code in decent shape.
  • Add proper unit tests for the generators and the generated code.

Support for other languages, such as Rust and Python -> follow-up.

@uhlajs @Skeleton003 Is this something you're looking for? There are no docs yet, you can take a look at ros2/test/protobuf/converter_tests.cc. Any specific functionality you're looking at?

@mvukov
Copy link
Copy Markdown
Owner Author

mvukov commented Feb 28, 2026

Also, one item high on my wish list is to add some option annotations to be able to define fixed-size arrays on the ROS side (such that one can use zero-copy transport in ROS on generated msgs).

- when multiple files in the same proto target
- when proto file name has underscores
@mvukov mvukov force-pushed the feature/proto_to_msg branch from e24ee8f to 75bcd02 Compare February 28, 2026 21:51
@mvukov mvukov force-pushed the feature/proto_to_msg branch from 8a645b7 to 8b52ab2 Compare March 7, 2026 16:30
@mvukov mvukov force-pushed the feature/proto_to_msg branch from e1a56f9 to 1c1b1f0 Compare March 8, 2026 21:40
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

Successfully merging this pull request may close these issues.

1 participant