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

how do I run my own node by launch file?

asked 2018-05-23 01:04:10 -0500

suoxd123 gravatar image

updated 2018-05-23 02:08:54 -0500

jayess gravatar image

I created one python file in my own pakage. when I execute the following code in command window, it works well.

rosrun my_package my_python.py

but when I add it in launch file and run it by following code, but it cannot work, just output one ERROR like:

roslaunch my_package my_launch.launch

ERROR cannot launch node of type [my_package/my_python.py]: can't locate node [my_python] in package [my_package]

No processes to monitor

my launch file like this(my_launch.launch):

<launch>
  <node name="my_python" type="my_python" pkg="my_package" />
</launch>
edit retag flag offensive close merge delete

Comments

2

Try type="my_python.py" instead?

ahendrix gravatar image ahendrix  ( 2018-05-23 01:51:06 -0500 )edit

Exactly, Thank you.

suoxd123 gravatar image suoxd123  ( 2018-05-23 03:44:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-05-23 02:14:01 -0500

jayess gravatar image

@ahendrix is correct. You need to have the type attribute for the node tag be the name of the executable, which in your case, is my_python.py. Therefore, my_launch.launch should be

<launch>
  <node name="my_python" type="my_python.py" pkg="my_package" />
</launch>

If you don't want to have the .py, then just remove it from the filename so that it'll be my_python.

For more information, please see http://wiki.ros.org/roslaunch/XML/node

edit flag offensive delete link more

Comments

Yes, Thank you for your explain. I am a freshman for ros programming, still not familar with its grammar.

suoxd123 gravatar image suoxd123  ( 2018-05-23 03:48:09 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-05-23 00:53:50 -0500

Seen: 2,721 times

Last updated: May 23 '18