I am new to ROS and am probably making an obvious mistake. I am running Noetic on Raspberry Pi 4 and it appears to have installed correctly. Specifically, I am trying to build a very simple node (based on an UDemy class) and keep getting rospy issues (or at least I think rospy issues).
Here is an outline of what I have done. I have tried many permutations and continue to get the same error.
catkin_make (run in catkin WS folder)
catkin_create_pkg (run in SRC folder)
Added scripts folder to the package folder
Ran catkin_make (tired this step and left out but error is the same)
Ran ". ~/ros_catkin_ws/devel/setup.bash" wile in catkin_ws folder because this seemed necessary based on what I read
Used touch command to create python file
Used chmod +x to make file executable
Wrote python script that I copied from Udemy class (prints "Hello")
Get the following error:
Traceback (most recent call last):
File "my_first_node.py", line 3, in <module>
import rospy
File "/home/pi/ros_catkin_ws/devel/lib/python3/dist-packages/rospy/__init__.py", line 34, in <module>
exec(__fh.read())
File "<string>", line 49, in <module>
File "/home/pi/ros_catkin_ws/src/ros_comm/rospy/src/rospy/client.py", line 60, in <module>
import rospy.impl.init
File "/home/pi/ros_catkin_ws/src/ros_comm/rospy/src/rospy/impl/init.py", line 54, in <module>
from .tcpros import init_tcpros
File "/home/pi/ros_catkin_ws/src/ros_comm/rospy/src/rospy/impl/tcpros.py", line 45, in <module>
import rospy.impl.tcpros_service
File "/home/pi/ros_catkin_ws/src/ros_comm/rospy/src/rospy/impl/tcpros_service.py", line 54, in <module>
from rospy.impl.tcpros_base import TCPROSTransport, TCPROSTransportProtocol, \
File "/home/pi/ros_catkin_ws/src/ros_comm/rospy/src/rospy/impl/tcpros_base.py", line 160
(e_errno, msg, *_) = e.args
^
SyntaxError: invalid syntax
Below is my python script for the node:
#!/usr/bin/env python3
import rospy
if __name__ == '__main__':
rospy.init_node('my_first_python_node')
rospy.loginfo("This node has been started")
rate = rospy.Rate(10)
while not rospy.is_shutdown():
rospy.loginfo("Hello")
rate.sleep()
Originally posted by newbie77 on ROS Answers with karma: 26 on 2021-02-04
Post score: 0
Original comments
Comment by phillipov on 2021-02-04:
ROS1 Noetic targets Python 3 instead of Python 2 (like previous ROS1 distros). Can you tell us the output of python --version
and python3 --version
on your Pi? The syntax error is giving me the hint that it's related to Python version issues.
Comment by jayess on 2021-02-04:
Not an answer, but you may want to change the title of your question to something more descriptive. You'll probably get more replies that way
Comment by newbie77 on 2021-02-05:
Thank you! I was running Python 2. Also, I wan't sourcing the setup.bash every time I turned the Pi on.
Comment by jayess on 2021-02-05:
@newbie77 you may want to write your solution up as an answer so that it can help others who may have the same problem in the future