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

Revision history [back]

click to hide/show revision 1
initial version

I'll try to answer your questions by linking to tutorials and docs, rather than repeating here.

I have no idea what these generators are. What are they exactly? Why do we need them?

and

Why on earth do we even need to have generators or generate files related to messages, services and actions?

They are used to generate code based on ROS interfaces which are used to exchange information over topics and services even between different languages. Because this is defined in a .msg file (which is a custom DSL) and needs to be used in each language (C++, Python, etc...) there is a necessary code generation step. You only need to do this if you have custom message or service definitions:

  • https://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv#Using_msg

I have no idea what the difference between creating a generator for messages and generating messages is.

Well, creating a generator is where you define how a message definition should be expanded into code. That's handled by genmsg and is implemented for several languages: C++ gencpp, Python genpy, Lisp genlisp:

  • https://wiki.ros.org/genmsg
  • https://wiki.ros.org/gencpp
  • https://wiki.ros.org/genpy
  • https://wiki.ros.org/genlisp

Where as generating messages is where you provide a message definition, and then the available message generators turn that message definition into language specific code. Again see:

  • https://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv#Using_msg

Why do we need these two separate steps?

The two things you mentioned add_message_files() and generate_messages() are separate steps because you can call the first kind of macro many times (you can think of it as building up a list of things that your package should generate code for), and the later is called once to actual generate the code. You should not call the latter after calling the former if you want it to work correctly.