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

Roslaunch can't locate node, but rosrun works fine

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

billtheplatypus gravatar image

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

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"?>
<launch>
        <node pkg="my_package" type="controller" name="controller"/>
</launch>

What I've tried so far:

  1. Changing the name of the executable from "controller" to "controller.py" (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

Comments

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 image gvdhoorn  ( 2018-05-16 04:33:44 -0500 )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 image gvdhoorn  ( 2018-05-16 04:34:22 -0500 )edit

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

billtheplatypus gravatar image billtheplatypus  ( 2018-05-16 09:06:27 -0500 )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 image gvdhoorn  ( 2018-05-16 09:09:20 -0500 )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 image gvdhoorn  ( 2018-05-16 09:09:58 -0500 )edit

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

billtheplatypus gravatar image billtheplatypus  ( 2018-05-16 09:10:45 -0500 )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 image gvdhoorn  ( 2018-05-16 09:36:22 -0500 )edit

I'll add that later today

billtheplatypus gravatar image billtheplatypus  ( 2018-05-16 09:39:01 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

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

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

Comments

Good to hear you resolved this.

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

gvdhoorn gravatar image gvdhoorn  ( 2018-05-17 02:20:43 -0500 )edit
0

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

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
-1

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

Alberto E. gravatar image

Hello! That's quite strange. What I would suggest you is that you rename everything to controller.py. I mean, rename the file to controller.py, and in the launch file, change also the type to type="controller.py". 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: https://www.youtube.com/watch?v=0WvJj... . Hope it helps!

edit flag offensive delete link more

Comments

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

billtheplatypus gravatar image billtheplatypus  ( 2018-05-16 09:05:33 -0500 )edit

Also, this video doesn't work

billtheplatypus gravatar image billtheplatypus  ( 2018-05-16 09:13:46 -0500 )edit

The video works for me

R. Tellez gravatar image R. Tellez  ( 2018-05-28 07:14:19 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 5,895 times

Last updated: Dec 11 '18