0
$\begingroup$

Rosanswers logo

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

Originally posted by billtheplatypus on ROS Answers with karma: 110 on 2018-05-15

Post score: 1


Original comments

Comment by gvdhoorn on 2018-05-16:
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 ..

Comment by gvdhoorn on 2018-05-16:
.. 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.

Comment by billtheplatypus on 2018-05-16:
@gvdhoorn, I do have the setup.bash source'd in my bashrc. I also ran catkin_make repeatedly.

Comment by gvdhoorn on 2018-05-16:
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 ..

Comment by gvdhoorn on 2018-05-16:
.. workspace changes.

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

Comment by billtheplatypus on 2018-05-16:
@gcdhoorn I know, and I've both closed and reopened bash, and sourced bashrc again

Comment by gvdhoorn on 2018-05-16:\

@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.

Comment by billtheplatypus on 2018-05-16:
I'll add that later today

Comment by gvdhoorn on 2018-05-16:
Is what you added your update? I don't see any info describing your workspace setup, layout or exact workflow.

Comment by billtheplatypus on 2018-05-16:
That wasn't it, but I just figured it out

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by billtheplatypus with karma: 110 on 2018-05-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by gvdhoorn on 2018-05-17:
Good to hear you resolved this.

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.