error python serial ros arduino

asked 2016-04-20 15:51:50 -0500

g-emad gravatar image

i am trying to make a node to send the ROS time to the arduino all the time through serial and am getting this error

syntax error near unexpected token `('
/home/gemad/catkin_ws/src/hello_world/scripts/ line 5: `ser = serial.Serial('/dev/ttyACM1',115200)'

the code of the node is :

import rospy 
import serial

ser = serial.Serial('/dev/ttyACM1',115200)

while not rospy.is_shutdown():
   ros_time = rospy.get_rostime()

any ide about what is wrong ?

edit retag flag offensive close merge delete


first of all, does your user have permissions to access the serial port?

second, ros_time is of type 'rospy.rostime.Time' so you can't write that directly to the serial port, you should do something like ros_time = ser.write(str(ros_time)) to send the time.

Gary Servin gravatar image Gary Servin  ( 2016-04-26 10:22:29 -0500 )edit