One of the most frequent question that we get in our customer support channels is an error when trying to ‘rosrun’ a Python file. The package is there, the file is there, the command has been typed in correctly, but it doesn’t want to run. Sounds familiar?
This is usually due to the file’s permission, which had to be set to be executable. So in this video, we will see how to do this, as well as explore a bit more on this subject. Beginners of ROS and the Linux system should find this very useful.
RELATED LINKS
▸ Original question
▸ ROS Development Studio (ROSDS)
▸ Robot Ignite Academy
Step1. Create a project in Robot Ignite Academy(RIA)
We have the best online ROS course available in RIA. It helps you learn ROS in the easiest way without setting up ROS environment locally. The only thing you need is a browser! Create an account here and start to browse the trial course for free now! We’ll use the ROS Basics in 5 Days course unit 2 as an example today.
Step2. How to make .py file executable
Here we create a package called test_exec using the following command
cd catkin_ws/src catkin_create_pkg test_exec rospy
We create a file called simple_topic_publisher.py under the src folder and copy the code from the course.
Then we compile the package using
cd ~/catkin_ws catkin_make
Now we try to run the .py file with rosrun test_exec simple_topic_publisher.py , but got the same error as the question.
How to solve this problem? We can execute the following command to give the file execute permission
chmod +x simple_topic_publisher.py
You can also check if the file has the permission with
ls -l
Then we run the file again with the rosrun command, the file is able to execute now.
Want to learn more?
If you are interested in learning ROS, please check our Robot Ignite Academy.
Edit by: Tony Huang
Feedback
Did you like this video? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.
0 Comments