ros2-dotnet / ros2_dotnet

.NET bindings for ROS2
Apache License 2.0
136 stars 54 forks source link

[Feature] C# API generation from .msg IDL files #114

Open andrew-otiv opened 1 year ago

andrew-otiv commented 1 year ago

Thanks for the library! I'm not a user yet, just investigating what is available for a new project.

Is there a .msg file -> C# static types code generator already that I just haven't found?

There are no .msg files in the repo, and the test cases seem to be generating their own types from a C# API.

(In a multi-language project, .msg files would be the IDL and source of truth for message layout.)

Thanks in advance!

hoffmann-stefan commented 1 year ago

Hi @andrew-otiv

The messages get generated by the rosidl_generator_dotnet package, which does this the same way as the message classes for the C++ and Python are generated. See https://github.com/ros2/rosidl. This whole process is deeply integrated into the colcon/ament/cmake build system that ROS uses and somewhat seems like magic ;)

This happens automatically in the ROS workspace when ros2_dotnet and the message packages get built. Just follow the README.md for setting up such a ROS workspace.