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

Why run python with rosrun?

asked 2022-05-23 09:44:16 -0500

bartb gravatar image

ROSnoob here with a fundamental question: What is the advantage of running python scripts with rosrun?

There is probably a good reason to use this methodology, perhaps due to dependencies or project scaling issues, but I have not seen clear arguments yet.

In order to get rosrun to work, I have to do a whole lot of other things such as making a catkin workspace, placing files, setting access to these files, sourcing the setup.bash etc etc and then running in terminal: rosrun <mypackagename> myscript.py While on the other hand I could simply run in terminal: python3 myscript.py

Sources that clearly explain this are also welcome.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-05-23 23:44:28 -0500

Vini71 gravatar image

Hi one good reason can be found in this documentation: http://wiki.ros.org/rosbash#rosrun

In a summarize, using:

  1. rosrun: You don't need to pass the path to execute the python program. You can run from any directory in terminal
  2. python: you need to execute from the folder your .py File is or need to pass the whole path to that file to be able execute it.

Other reasons I also don't know... What I know is that this python program is interpreted as a Ros node when compiled with catkin make. Then I infer that a Ros node must have additional attributes as a simple python program ...

edit flag offensive delete link more

Comments

I don't see the need of passing the full path of the file as a problem, personally. I have the feeling there are more fundamental reasons behind this approach to running the same piece of code.

Else we could just add the particular folder where the file is to path, right?

bartb gravatar image bartb  ( 2022-06-13 05:34:05 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-05-23 09:42:06 -0500

Seen: 121 times

Last updated: May 23 '22