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

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
5

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

Comments

@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

Question Tools

1 follower

Stats

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

Seen: 9,890 times

Last updated: Oct 19 '18