Naming convention of the executable of C++ file

How do we usually name the executable of a C++ file?
By default it is ${PROJECT_NAME}_node in the CmakeList.txt, shall we always change it or not?

Here is the lesson note:

5- Modify the CMakeLists.txt file in order to generate an executable from the C++ file you have just created.

Note: This is something that is required when working in ROS with C++. When you finish this Exercise, you’ll learn more about this subject. For now, just follow the instructions below.

In the Build section of your CMakeLists.txt file, add the following lines:

add_executable(simple src/simple.cpp) add_dependencies(simple ${simple_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) target_link_libraries(simple ${catkin_LIBRARIES} )

HINT: If you have a look at the file, you’ll see that those lines are already in the file, but they are commented. If you feel so, you can uncomment those lines and modify them like the ones we provide above, instead of simply adding them to the end of the section.

You don’t need to follow a naming convention. What I would recommend is that you name your node to reflect what it does, considering especially that you can have two or more nodes in the same package. e.g.

  • talker_node
  • listener_node

You can even omit the “_node” part entirely.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.