SHARE
TWEET

Untitled

a guest Oct 13th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PiBot import PiBot
  2. import rospy
  3.  
  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_wheels_speed(15)
  12.  
  13. while distance_from_object > 0.2:
  14.     rospy.sleep(0.05)
  15.     distance_from_object = robot.get_front_middle_ir()
  16.     print(robot.get_left_wheel_encoder())
  17.     print(robot.get_right_wheel_encoder())
  18. robot.set_wheels_speed(0)
  19. print(robot.get_left_wheel_encoder())
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