0
$\begingroup$

Rosanswers logo

Hello there,

I am trying to launch a script called mtnode.py from a package called xsens_drive. When I use rosrun it works perfectly, however i have difficulty to launch it with roslaunch. This is the syntax that I use:

  <node pkg="xsens_drive" name="mtnode.py" type="mtnode.py" output="screen">
        <param name="frame_id" value="base_link" />
  </node> 

and this is the warning and error form the roslaunch:

WARNING: WARN: illegal <node> name 'mtnode.py'.
http://ros.org/wiki/Names
This will likely cause problems with other ROS tools.
Node xml is <node name="mtnode.py" output="screen" pkg="xsens_drive" type="mtnode.py">
        <param name="frame_id" value="base_link"/>
  </node>

and the error:

ERROR: cannot launch node of type [xsens_drive/mtnode.py]: xsens_drive
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/sherpa/catkin_ws/src
ROS path [2]=/opt/ros/indigo/share
ROS path [3]=/opt/ros/indigo/stacks

I tried different combination of name and type without .py with no luck, I am using ros indigo

Thanks in advance


Originally posted by mohsen1989m on ROS Answers with karma: 397 on 2016-03-22

Post score: 9

$\endgroup$

4 Answers 4

0
$\begingroup$

Rosanswers logo

<node pkg="xsens_drive" name="mtnode.py" type="mtnode.py" output="screen"> 

I think the package is actually called xsens_driver, so the following should work:

<node pkg="xsens_driver" name="mtnode" type="mtnode.py" output="screen"> 
  ..
</node>

The type for a Python script is always just the script itself. The name can be anything, but must follow the ROS naming conventions.


Originally posted by gvdhoorn with karma: 86574 on 2016-03-22

This answer was ACCEPTED on the original site

Post score: 20


Original comments

Comment by mohsen1989m on 2016-04-07:
Thanks, yep that was a stupid mistake of mine...

Comment by Haresh Karnan on 2018-02-26:
This was useful, Thankyou !

Comment by meterix on 2018-06-11:
I did the same mistake, thank you!

Comment by Avio on 2018-06-29:
In my case (Kinetic), the node name was not sufficient, I had to specify nodename.py.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Additionally, make sure that the python script is executable (has execute bit set to 1), i.e. can be run with ./my_script.py


Originally posted by Rufus with karma: 1083 on 2020-01-09

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$
0
$\begingroup$

Rosanswers logo

Make the python script executable chmod +x python_script_name.py

So give pkg= "name of package where script lies" name ="name of python script without extension" type="name of python scrupt with extension"

Example :

<node pkg="v1robot_description" name="fake_encoder_count" type="fake_encoder_count.py" output="screen"/>

Name of python script in my case: fake_encoder_count.py Name of my ROS package : v1robot_description


Originally posted by Sanjuna Mariam Mathews with karma: 51 on 2020-08-09

This answer was NOT ACCEPTED on the original site

Post score: 4

$\endgroup$
0
$\begingroup$

Rosanswers logo

As, @rufus mentioned above make sure the file is executable. You can to do that with below command: $ chmod +x python_script.py


Originally posted by Yash Sahu with karma: 71 on 2021-08-07

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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