ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Which languages (and target names) does genmsg support?

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

rubicks gravatar image

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

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)

--- https://docs.ros.org/api/genmsg/html/...

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
0

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

rubicks gravatar image

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

Collecting relevant comments from the answer from @janindu :

This loop in genmsg invokes all available generators which are on their own create their targets: https://github.com/ros/genmsg/blob/f9...

--- 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.

References:

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

edit flag offensive delete link more
0

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

janindu gravatar image

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

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

Comments

@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 image rubicks  ( 2019-03-26 09:26:44 -0500 )edit

@rubicks, I was referring to the ROS documentation http://wiki.ros.org/ROS/Introduction 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 image janindu  ( 2019-03-26 09:30:36 -0500 )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 image rubicks  ( 2019-03-26 09:58:45 -0500 )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 image gvdhoorn  ( 2019-03-26 11:53:42 -0500 )edit

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

rubicks gravatar image rubicks  ( 2019-03-26 12:10:19 -0500 )edit
2

This loop in genmsg invokes all available generators which are on their own create their targets: https://github.com/ros/genmsg/blob/f9...

Dirk Thomas gravatar image Dirk Thomas  ( 2019-03-26 12:11:12 -0500 )edit
3

@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 image gvdhoorn  ( 2019-03-26 12:18:14 -0500 )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 image rubicks  ( 2019-03-26 12:25:01 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 524 times

Last updated: Mar 26 '19