ERROR: cannot launch node of type [topic_publisher/simple_topic_publisher]: can’t locate node [simple_topic_publisher] in package [topic_publisher]

can someone helps me please

how can i solve this problem

ERROR: cannot launch node of type [topic_publisher/simple_topic_publisher]: can’t locate node [simple_topic_publisher] in package [topic_publisher]

this is my launchfile

<!-- My Package launch file -->

<node pkg="topic_publisher" type="simple_topic_publisher" name="topic_publisher"  output="screen">

</node>
1 Like

Hi @herrsidje,

Have you run

cakin_make
source devel/setup.bash

?
If so, then you need to review your CMakeLists.txt because it means you have not setup your C++ source file to be correctly compiled, as indicated in the notes.


Btw, welcome to the Community!

thanks for answer.
i executed the catkin_make and Source devel/setup.bash command
but it still appear the same error.
my cmakelist look like this

add_executable(simple_topic_publisher src/simple_topic_publisher.cpp)

add_dependencies(simple_topic_publisher ${simple_topic_publisher_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(simple_topic_publisher

${catkin_LIBRARIES}

)

The problem is that your C++ executable has not been compiled even if everything appears to be correctly setup. Check the following:

  1. Did catkin_make run without errors, indicating that a C++ executable was being generated from your C++ source? In any case, try removing the build and devel folders and run the following again, taking note of the messages generated by catkin_make.
# run from catkin_ws directory
rm -rf build/ devel/
cakin_make
source devel/setup.bash
  1. Did you copy CMakeLists.txt or package.xml? You should avoid copying CMakeLists.txt or package.xml - better to edit them manually, following the notes - to avoid typo errors that usually result. You should create your package with catkin_create_pkg and only copy source or launch files, if necessary. You should then manually edit the necessary sections of CMakeLists.txt and package.xml.
3 Likes

thanks for your answers. it seems to work

the solution was to manually edit the Cmakelists

thank you for your support

the solution was to manually edit the Cmakelists

1 Like

I have the same problem. The cpp file seems to be not compiled. I tried everything. I added this code manually in the CMakeLists.txt :

add_executable(simple_topic_publisher src/simple_topic_publisher.cpp)
add_dependencies(simple_topic_publisher ${simple_topic_publisher_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(simple_topic_publisher
${catkin_LIBRARIES}
)

I tried as well to make sure that Ros takes the changes made through sourcing my workspace : source devel/setup.bash.
I made sure that the launch file is syntaxically correct.(btw , isn’t the launch of @herrsidje missing the " < launch >" and the “< /launch >” above and below ?
I thought as well that Ros haven’t detected my new created Package (in that case, I can’t use roslaunch) so I tried to referesh the package list using : rospack profile .
I think i have tried everything , but i still get the error:

… logging to /home/user/.ros/log/26fe808a-8295-11ed-9842-0242c0a8a006/roslaunch-1_xterm-6543.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://1_xterm:34849/

SUMMARY

PARAMETERS

  • /rosdistro: noetic
  • /rosversion: 1.15.9

NODES
/
topic_publisher (topic_publisher_pkg/simple_topic_publisher)

ROS_MASTER_URI=http://1_simulation:11311

ERROR: cannot launch node of type [topic_publisher_pkg/simple_topic_publisher]: Cannot locate node of type [simple_topic_publisher] in package [topic_publisher_pkg]. Make sure file exists in package path and permission is set to executable (chmod +x)
No processes to monitor
shutting down processing monitor…
… shutting down processing monitor complete

maybe because i placing the code to add in CMakeList.txt in the wrong place ? But I am pretty sure that it should be at the end of the build section!

Okay I have just solved it through deleting : rm -rf build/ devel/ as @bayodesegun said. Any explanation for that deletion? This would be useful for futur use in case of not being able to roslaunch a package, I delete the build/devel/ and compile again!

Some files in build and devel indicate that a package has already been compiled, so to reliably recompile a package you need to delete them.

1 Like

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