error python serial ros arduino
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/ros_time_arduino.py: line 5: `ser = serial.Serial('/dev/ttyACM1',115200)'
the code of the node is :
import rospy
import serial
ser = serial.Serial('/dev/ttyACM1',115200)
rospy.init_node('ros_time_arduino')
while not rospy.is_shutdown():
ros_time = rospy.get_rostime()
ser.write(ros_time)
mont=ser.readline()
print(mont)
any ide about what is wrong ?
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.