Ask Your Question

Roslaunch can't locate node, but rosrun works fine

asked 2018-05-15 18:44:29 -0600

billtheplatypus gravatar image

updated 2018-05-16 15:39:46 -0600

I'm working on a simple node written entirely in python. To make it work with roslaunch, I made it into a package. I got the package working fine, and I can run rosrun my_package controller just fine. However, when I run it in a roslaunch file, it gives the error ERROR: cannot launch node of type [my_package/controller]: can't locate node [controller] in package [my_package] What is wrong with my environment or package? As a minimal example, I get this with the simple launch file:

<?xml version="1.0"?>
        <node pkg="my_package" type="controller" name="controller"/>

What I've tried so far:

  1. Changing the name of the executable from "controller" to "" (And adjusting in the launch file)
  2. Setting 777 permissions on the executable
  3. Relaunching the terminal
  4. sourceing .bashrc again (which has setup.bash in it)
  5. Rerunning catkin_make a lot
edit retag flag offensive close merge delete


The name of the file should not influence this at all. To verify, I just created a toy workspace with a single rospy pkg that contains a controller file containing the default Talker node. After building the workspace, both rosrun and roslaunch (after adding a launch file) can ..

gvdhoorn gravatar imagegvdhoorn ( 2018-05-16 04:33:44 -0600 )edit

.. find the script and start it.

It is much more likely the OP has a typo somewhere, the file is not in the correct location, he forgot to catkin_make his workspace, he forgot to source the correct setup.bash (perhaps used a new terminal) or something else is not entirely correct.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-16 04:34:22 -0600 )edit

@gvdhoorn, I do have the setup.bash source'd in my bashrc. I also ran catkin_make repeatedly.

billtheplatypus gravatar imagebilltheplatypus ( 2018-05-16 09:06:27 -0600 )edit

This is probably not the solution, but do please realise that if you have source .../setup.bash in your .bashrc, it will only actually source your workspace if/when you open a new terminal, start bash or source $HOME/.bashrc. It will not happen automatically whenever your ..

gvdhoorn gravatar imagegvdhoorn ( 2018-05-16 09:09:20 -0600 )edit

.. workspace changes.

If you haven't sourced after you built your workspace, then new pkgs added afterwards will not be picked up.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-16 09:09:58 -0600 )edit

@gcdhoorn I know, and I've both closed and reopened bash, and sourced bashrc again

billtheplatypus gravatar imagebilltheplatypus ( 2018-05-16 09:10:45 -0600 )edit

@gcdhoorn I know, and I've both closed and reopened bash, and sourced bashrc again

then I believe we're going to need a little more info. Please tell us how you setup your workspace (paths, layout, etc), what your workflow is, show the contents of your pkg (ls -al), etc.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-16 09:36:22 -0600 )edit

I'll add that later today

billtheplatypus gravatar imagebilltheplatypus ( 2018-05-16 09:39:01 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2018-05-16 15:21:12 -0600

billtheplatypus gravatar image

I found the issue. I had originally wrote the code for the node in a different directory. When it came time to make the package, i just symlinked the src directory of the package to the directory with the code I had written. For some reason, that breaks it. I removed the symlink and just copied the directory, and now it works great.

edit flag offensive delete link more


Good to hear you resolved this.

It was partially why I asked you about your workspace setup though.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-17 02:20:43 -0600 )edit

answered 2018-12-11 13:23:36 -0600

achille gravatar image

Slightly different error, but this might help someone who stumbled upon the same problem later: When you get

ERROR: cannot launch node of type [path_to_file] package_path
ROS path [0]=/opt/ros/...

triple check your launch file. In my case I had written my launch file as:

<node name="talker" pkg="$(find beginner_tutorials)" type="talker"/> instead of: <node name="talker" pkg="beginner_tutorials" type="talker"/>

So make sure you don't include the find tag.

edit flag offensive delete link more

answered 2018-05-16 04:28:04 -0600

Alberto E. gravatar image

Hello! That's quite strange. What I would suggest you is that you rename everything to I mean, rename the file to, and in the launch file, change also the type to type="". If you do this, and the file has execution permissions, it has to work OK. I've created a short video trying to reproduce your case, you can have a look here: . Hope it helps!

edit flag offensive delete link more


I tried it with at first, and a few times while debugging and it has made no change.

billtheplatypus gravatar imagebilltheplatypus ( 2018-05-16 09:05:33 -0600 )edit

Also, this video doesn't work

billtheplatypus gravatar imagebilltheplatypus ( 2018-05-16 09:13:46 -0600 )edit

The video works for me

R. Tellez gravatar imageR. Tellez ( 2018-05-28 07:14:19 -0600 )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



Asked: 2018-05-15 18:44:29 -0600

Seen: 1,756 times

Last updated: Dec 11 '18