ROS Basics in 5 days - Python - Exercise 3.1

Hello, please help me, I’m super stuck. I think it’s telling me that my python file is not found when I try roslaunch, but I’ve tried everything I can think of, 10 times for the most part, I even deleted and rebuilt the package once or twice. I am not working with nothing but an exact copy of the solution, and it still isn’t working.

Thanks so much!

The problem is that you did not provide execution permissions to the Python file.

Go to unit_3_services/src and the provide execution permissions to the file exercise_3_1.py:

$ chmod +x exercise_3_1.py

Let me know if that works

1 Like

Oh man, I knew it was going to be something that I’ve already done 20 times but was slipping my mind, yes that worked straight away, thanks so much! :smiley:

2 Likes

:grinning: Happy it was something so easy to solve!

Hey! I have the problem with the same exercise. I copied the python program, which is already writen:

#! /usr/bin/env python

import rospy
from std_msgs.msg import Int32

rospy.init_node(‘topic_publisher’)
pub = rospy.Publisher(’/counter’, Int32, queue_size=1)
rate = rospy.Rate(2)
count = Int32()
count.data = 0
rostopic
while not rospy.is_shutdown():
pub.publish(count)cd …
count.data += 1
rate.sleep()

But when i try to run it, it gives me this:

rosrun my_examples_pkg simple_topic_publisher.py
File “/home/user/catkin_ws/src/my_examples_pkg/scripts/simple_topic_publisher.py”, line 13
pub.publish(count)cd…
^
SyntaxError: invalid syntax

Does anybody now how to fix this?
Thank you for your answer

Oh, I have found the problem.
Thank you anyway.