Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def camera_feedback():
  2. GPIO.setmode(GPIO.BCM)
  3. GPIO.setup(but_restart,GPIO.IN)
  4.  
  5. #~ GPIO.add_event_detect(but_restart, GPIO.RISING, callback=RRestart, bouncetime=1000)
  6. rospy.init_node("GPIO_SIGNAL", anonymous=False)
  7. rospy.Timer( rospy.Duration(0.1),RRestart)
  8. rospy.spin()
  9. GPIO.cleanup()
  10.  
  11. if __name__ == "__main__":
  12. try:
  13. camera_feedback()
  14. except rospy.ROSInterruptException:
  15. pass
  16.  
  17. def RRestart(channel):
  18. global flag_reset2
  19. global RR_alr
  20. global flag_inreset
  21.  
  22. #~ if (GPIO.input(but_restart) == 1 and flag_reset2 == False):
  23. #~ flag_inreset = True
  24. #~ flag_reset2 = True
  25. #~ elif (GPIO.input(but_restart) == 0 and flag_reset2 == True):
  26. #~ flag_reset2 = False
  27. channel = GPIO.wait_for_edge(but_restart, GPIO.RISING)
  28.  
  29. if channel is None:
  30. print("timeout")
  31. else:
  32. print("edge detected on channel",channel)
  33. flag_inreset = True
  34.  
  35. if (flag_inreset ==True):
  36. print("Restart")
  37. RR_alr = True
  38. print("waiting killing now and then restart")
  39. flag_inreset = False
  40. call(['bash','/home/ubuntu/kill_restart.sh'])
  41. print("done restart")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement