ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Naming conventions for ros2 msgs

Hi,

Will it be allowed to put ‘_’ in the name of a ros2 msg?

In ros2 wiki it is not defined: https://github.com/ros2/ros2/wiki/About-ROS-Interfaces

In ros1 wiki it is mentioned to put the name in camelcase and therefore no underscore seems to be allowed: http://wiki.ros.org/ROS/Patterns/Conventions under 2.3 Messages

Is this also the case for ros2?

For ROS 2 the format of the interface files is specified in http://design.ros2.org/articles/interface_definition.html#naming-of-messages-and-services. The naming scheme for the filename hasn’t changed since ROS 1 and still only allows alphanumeric characters.

1 Like

I realize this is an old thread, but (I hope) this is related: is there documentation somewhere about the naming conventions for the generated message headers in ROS 2? The .msg files are all CamelCase, but the .hpp file names all seem to be converted to snake_case, which was a bit confusing at first.

@dirk-thomas’s link above mentions

Both file names must use an upper camel case name and only consist of alphanumeric characters.

So that’s for .msg & .srv files.

As for snake_case headers, that’s just file naming convention. While it doesn’t explicitly talk about it, the Introduction to msg and srv interfaces tutorial (although it’s a draft) does use snake_case headers.

@christophebedard Thanks, yes, I realize that now. My confusion was that, from the tutorial, I thought it just made the file names lower case (in the tutorial Num.msg becomes num.hpp). So I had defined a message file like Foo3D.msg and I tried including it as foo3D.hpp, which didn’t work. I had to use foo3_d.hpp.