Ask Your Question

Which languages (and target names) does genmsg support?

asked 2019-03-25 17:25:49 -0600

rubicks gravatar image

updated 2019-03-26 09:28:57 -0600

The documentation for genmsg seems to indicate that generated targets follow language-name conventions.

E.g. if you target foo depends on the C++ messages of your current bar project, you need to add: add_dependencies(foo bar_gencpp)


Is there a list of these supported languages? Is there documentation explaining how the genmsg cmake macros generate target names?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2019-03-26 14:22:51 -0600

rubicks gravatar image

updated 2019-03-26 14:27:41 -0600

Collecting relevant comments from the answer from @janindu :

This loop in genmsg invokes all available generators which are on their own create their targets:

--- dirk-thomas

Generators essentially register as plugins against genmsg using a message_generator tag in the export section of their manifests.

--- gvdhoorn

With regard to the enumeration of packages that provide language generators, this is entirely dependent on which packages are present; for most catkin workspaces, this is a function rosdep and any package.xml files present.

However, for the common case where a given project depends on the message_generation package, the following generators are dependencies thereof and guaranteed to be present:

In this case, the generate_messages macro provided by genmsg will understand (eponymous) LANGS option arguments for each of these five generators.


Much thanks to @janindu, @gvdhoorn, and @dirk-thomas for all your help.

edit flag offensive delete link more

answered 2019-03-26 01:12:21 -0600

janindu gravatar image

updated 2019-03-26 01:13:18 -0600

ROS is a framework that is implemented in several languages such as C++, Python and Lisp. There are experimental libraries for Java and Lua among others as well (source)

ROS messages are defined using a simple description language .

To use these messages in a ROS implementation (such as the C++ implementation roscpp), these messages need to be converted into a language specific data structure (C++ class / struct). With generate_message, system will build language specific files (for roscpp, it creates .h header files for each message, which is why when we define a custom_msg.msg, to use it with roscpp we #inclde <custom_msg.h>).

To support multiple languages, the simple description language restricts field names to start with an alphabetic character followed by alphanumeric and underscore characters ( i.e. [a-zA-Z][a-zA-Z1-9_]*]). Using keywords in common languages is discouraged to avoid confusion, however they are legal.

Currently, C++, Python and Lisp are among the supported languages. The corresponding target names are bar_gencpp, bar_genpy and bar_genlisp for project bar that contains the dependent messages.

edit flag offensive delete link more


@janindu thanks very much. When you mention "languages such as C++, Python, and Lisp", what documentation are you referencing? Also, the regular expression you show is specific to message field names, whereas my question concerns cmake target names.

rubicks gravatar imagerubicks ( 2019-03-26 09:26:44 -0600 )edit

@rubicks, I was referring to the ROS documentation And yes, the regex was a bit of extra information. The canoe target names as mentioned in the answer are ‘bar_gencpp’, ‘bar_genpy’ and bar_lisp

janindu gravatar imagejanindu ( 2019-03-26 09:30:36 -0600 )edit

@janindu , okay, but where is this documented? It would seem genmsg generates cmake target names of the form ${project}_gen${lang}, but I can't find this documented anywhere.

rubicks gravatar imagerubicks ( 2019-03-26 09:58:45 -0600 )edit

This answer is incomplete: there are code generators for Java and NodeJS as well (and some others, but those are largely unmaintained).

gvdhoorn gravatar imagegvdhoorn ( 2019-03-26 11:53:42 -0600 )edit

@gvdhoorn , do I understand correctly that such code generators merely exist; i.e., that there is no canonical enumeration thereof?

rubicks gravatar imagerubicks ( 2019-03-26 12:10:19 -0600 )edit

This loop in genmsg invokes all available generators which are on their own create their targets:

Dirk Thomas gravatar imageDirk Thomas ( 2019-03-26 12:11:12 -0600 )edit

@rubicks: generators essentially register as plugins against genmsg using a message_generator tag in the export section of their manifests (here for gencpp fi). I'm not sure there is any convenience script that could look for all such packages on your system.

An indirect way to figure out which generators exist would be to check the Used by section of the Package Links box on the right side of the package header of the wiki/genmsg page. All generators must (well, should, if they want to benefit from it) depend on genmsg, so inspecting that list should give you an idea for which generators exist.

Note that some packages erronously state a dependency on genmsg, but are clearly not generators.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-26 12:18:14 -0600 )edit

@gvdhoorn , ah, okay. Thanks very much for explaining --- it's not so much that generators are collected and named, it's that each is a package of a certain form and brought in as a dependency. Thanks again.

rubicks gravatar imagerubicks ( 2019-03-26 12:25:01 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-03-25 17:25:49 -0600

Seen: 130 times

Last updated: Mar 26 '19