daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import SerialHandler
  2. import threading
  3. import time
  4.  
  5. serialHandler = SerialHandler.SerialHandler("/dev/ttyACM0")
  6. serialHandler.sendPidActivation(True)
  7.  
  8. ev1 = threading.Event()
  9. serialHandler.readThread.addWaiter("MCTL", ev1)
  10. ev2 = threading.Event()
  11. serialHandler.readThread.addWaiter("BRAK", ev2, print)
  12.  
  13. sent = serialHandler.sendMove(-0.5,5.0)
  14. if sent:
  15.     isConfirmed = ev1.wait(timeout=1.0)
  16.     ev1.clear()
  17.     if(isConfirmed):
  18.         print("\tMoving was confirmed!")
  19.     else:
  20.         try:
  21.             raise ConnectionError('1', 'Response was not received!')
  22.         except Exception as e:
  23.             print (e)
  24.  
  25. else:
  26.     print("Sending problem")
  27. time.sleep(3.0)
  28. sent = serialHandler.sendBrake(0.0)
  29. if sent:
  30.     isConfirmed = ev2.wait(timeout=1.0)
  31.     ev2.clear()
  32.     if(isConfirmed):
  33.         print("\tBraking was confirmed!")
  34.     else:
  35.         try:
  36.             raise ConnectionError('2', 'Response was not received!')
  37.         except Exception as e:
  38.             print (e)
  39. else:
  40.     print("Sending problem")
  41.    
  42. serialHandler.sendBezierCurve(1+1j,1.56+0.44j,1.56-0.44j,1.0-1.0j,6.0,True)
  43. serialHandler.sendPidActivation(False)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top