SHARE
TWEET

Untitled

a guest Oct 13th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. from PiBot import PiBot
  3. import rospy
  4. # Create a robot instance
  5. robot = PiBot()
  6.  
  7. # Get distance from object using the front middle IR sensor
  8. distance_from_object = robot.get_front_middle_ir()
  9.  
  10. # Drive towards object
  11. robot.set_left_wheel_speed(17)
  12. robot.set_right_wheel_speed(-17)
  13. print("turning around now")
  14.  
  15. while distance_from_object == 1:
  16.     distance_from_object = robot.get_front_middle_ir()
  17.     print(distance_from_object , "2")
  18. """while 0.5 < distance_from_object < 0.99:
  19.     distance_from_object = robot.get_front_middle_ir()
  20.     print(distance_from_object, "3")
  21.     if 0 < distance_from_object < 0.5:
  22.         print("i see walls 4")
  23.     else:
  24.         print("5")"""
  25. while 0 < distance_from_object < 0.5:
  26.     distance_from_object = robot.get_front_middle_ir()
  27.     robot.set_wheels_speed(0)
  28.     print(distance_from_object , "1")
  29.     if 0 < distance_from_object < 0.5:
  30.         print("i see walls 6")
  31.         robot.set_wheels_speed(17)
  32.  
  33.  
  34. if __name__ == "__main__":
  35.     print("Hello, I started running!")
  36.     rospy.sleep(1.0)
  37.     print("Resumed after waiting 1 second!")
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