\ BUMPER.TXT - THE SEEKER'S OBSTACLE AVOIDANCE
\
\ REQUIRES: DIFFMOTOR3.TXT TOUCH.TXT

DECIMAL

0 SENSOR_BOOL_MAKE

\ The SEEKER_AVOID just backs the bot up for 1 second

: SEEKER_AVOID ( -- )
  BOT_REVERSE
  100 0 timer_SET
  BEGIN 0 timer_GET 0= UNTIL
  BOT_STOP ;

\ The CHECK_BUMPER word reverses the sense of the touch
\ sensor before deciding to back up. Returns TRUE if
\ we've hit an obstacle.

: CHECK_BUMPER ( -- f )
  0 SENSOR_BOOL? 0= DUP
  IF SEEKER_AVOID
  THEN ;
