Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. from robolink import *
  2. from robodk import * # Robot toolbox
  3. from tkinter import * #
  4. from threading import * # Import Threading
  5. import serial # Import USB -connection
  6.  
  7. RDK = Robolink() # Sets Robolink to new variable RDK
  8. robot = RDK.Item('KUKA KR 210 L150-2') # Assigning the item, as our robot
  9. robot.setJoints([0, 0, 0, 0, 0, 0]) # Setting the robot to default position
  10. arduinoData = serial.Serial('COM5',9600) # Gathering data from the serial port
  11. newData = bytes(arduinoData.read()) #Sets the data readable from the usb
  12. decodedData = newData.decode("utf-8")
  13.  
  14. #Defining 4 test targets
  15. target1 =RDK.Item('target 1')
  16. target2 =RDK.Item('target 2')
  17. target3 =RDK.Item('target 3')
  18. target4 =RDK.Item('target 4')
  19. crash = False
  20. def sensor_check(): # Creating a function that controll the sensor
  21. print(decodedData)
  22. while decodedData.__contains__("1"):
  23. print("Contains 1")
  24. print(newData)
  25. robot.Pause(500) #Stops the robot
  26. crash = True
  27.  
  28. def robot_move(): # The robot starts to move in a while loop
  29. while crash == False: # It stops if crash equals to true
  30. robot.moveJ(target1)
  31. robot.moveJ(target2)
  32. robot.moveJ(target3)
  33. robot.moveJ(target4)
  34. sensor_check() # Intialize sensorcheck
  35. robot_move() # Intaliaze robot movement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement