Ask Your Question

Do I have to modify CMakeLists.txt for a python node?

asked 2018-10-19 04:21:28 -0500

Spyros gravatar image

updated 2018-10-19 04:58:19 -0500

Delb gravatar image

I try to write a python node running in my package. Before I run catkin_make and rosrun, do I have to modify my CMakeLists.txt file as we did in the case of C++ node it the tutorial at Step 3?

I am new in ROS, I use ubuntu 16.04, ROS kinetic and python 2.7

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-19 05:12:43 -0500

Delb gravatar image

You are referring to a tutorial with roscpp, there is the same one using rospy here.

You have to modify the CmakeLists.txt in python too but not as systematically as with roscpp. In python if you want to run a simple node with no dependencies you just have to make sure to use the command chmod +x to get an executable that rosrun can use. In cpp, whenever you create a node you have to create the executable from the CMakeLists.txt like that (taken from your tutorial) :

add_executable(talker src/talker.cpp)

You don't need to do that in python.

But you will have to modify the CMakeList if you want to create a custom message, to use a client/server and to list all the dependencies of your package.

edit flag offensive delete link more


@Delb you are right about my tutorial reference. I read the rospy tutorial but I wasn't sure if it takes the CMakeLists.txt modification as default from the previous tutorial (roscpp).In case I want to create a custom message, client/server, list dependencies, I have follow the same steps as roscpp?

Spyros gravatar image Spyros  ( 2018-10-19 06:16:49 -0500 )edit

If you follow all the links from the python tutorial I gave you 'll end up creating Msg and Srv directly to the configuration of the CMakeLists.txtso yes.

Delb gravatar image Delb  ( 2018-10-19 06:36:12 -0500 )edit

One piece of advice when you are wondering those things : try, experience yourself. If you don't change the CMakeLists.txt you'll direclty see error messages if it had to be changed.

Delb gravatar image Delb  ( 2018-10-19 06:38:09 -0500 )edit

Thank you! Your answer helped me to understand what I have to do.

Spyros gravatar image Spyros  ( 2018-10-19 06:39:43 -0500 )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: 2018-10-19 04:21:28 -0500

Seen: 4,846 times

Last updated: Oct 19 '18