From: Federica Di Lauro Date: Tue, 28 Jan 2020 09:20:19 +0000 (+0100) Subject: fix python scripts, now looping till we can open serial port X-Git-Url: http://git.leonardobizzoni.com/?a=commitdiff_plain;h=d89c52fccacfdc64d7339c434917aad47ad624f7;p=pioneer-stm32 fix python scripts, now looping till we can open serial port --- diff --git a/utils/catkin_ws/joypad.launch b/utils/catkin_ws/joypad.launch index 69f8ec6..e3765a8 100644 --- a/utils/catkin_ws/joypad.launch +++ b/utils/catkin_ws/joypad.launch @@ -1,5 +1,5 @@ - + diff --git a/utils/catkin_ws/src/joypad_bridge/scripts/cmd_vel_transmitter.py b/utils/catkin_ws/src/joypad_bridge/scripts/cmd_vel_transmitter.py index ae2859c..381ae56 100755 --- a/utils/catkin_ws/src/joypad_bridge/scripts/cmd_vel_transmitter.py +++ b/utils/catkin_ws/src/joypad_bridge/scripts/cmd_vel_transmitter.py @@ -2,36 +2,35 @@ import rospy, serial, struct, time from geometry_msgs.msg import Twist +from serial import SerialException ser = serial.Serial( - port='/dev/ttyUSB0', baudrate=115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, rtscts=False) -current_millis = 0 -last_millis = 0 - def callback(data): - global current_millis - global last_millis - #da fixare linear = -data.linear.x - angular = -data.angular.z - last_millis = current_millis - current_millis = int(round(time.time() * 1000)) + angular = -data.angular.z #da fixare? rospy.loginfo('I heard %f %f', linear, angular) - if (1): - msg_output = struct.pack('