def __init__(self): rospy.Subscriber("/gazebo/ft_sensor_topic", Wrench, self.call_ft) while not rospy.is_shutdown(): rospy.loginfo("Connecting to %s at %d baud" % (port_name, baud)) if (flag == 0): #do this try: client = SerialClient( port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test, auto_reset_timeout=auto_reset_timeout) client.run() except KeyboardInterrupt: break except SerialException: sleep(1.0) continue except OSError: sleep(1.0) continue else: print("Too much force/torque.. cannot execute plan")
# Number of seconds of sync failure after which Arduino is auto-reset. # 0 = no timeout, auto-reset disabled auto_reset_timeout = int(rospy.get_param('~auto_reset_timeout', '0')) # for systems where pyserial yields errors in the fcntl.ioctl(self.fd, TIOCMBIS, \ # TIOCM_DTR_str) line, which causes an IOError, when using simulated port fix_pyserial_for_test = rospy.get_param('~fix_pyserial_for_test', False) # TODO: do we really want command line params in addition to parameter server params? sys.argv = rospy.myargv(argv=sys.argv) if len(sys.argv) >= 2: port_name = sys.argv[1] while not rospy.is_shutdown(): rospy.loginfo("Connecting to %s at %d baud" % (port_name, baud)) try: client = SerialClient(port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test, auto_reset_timeout=auto_reset_timeout) client.run() except KeyboardInterrupt: break except SerialException: sleep(1.0) continue except OSError: sleep(1.0) continue