The finite state machine which controls "Ally". There is also a high resolution version and a Scalable Vector Graphics version of the drawing. The original Graphviz file which produced the SVG file is also available.

On power up, the robot waits one second and then drives forward in a straight line. If it encounters an obstacle, it backs up a bit and turns away from the obstacle before moving forward again.

If the robot re-encounters an obstacle within the first few seconds of resuming forward motion, it again backs up and turns further in the same direction, irrespective of which side the second obstruction is detected.

This behaviour prevents the robot from getting stuck in corners and has proved to be very effective.

The Common Lisp source code for the finite state machine interpreter and printer can be found in state-machine.lisp which includes the definition of Ally's finite state machine and a sample script to run on it. This definition is also reproduced below.

(make-machine ally
  (start nil (1 forward))
  (forward :forward (:left-bumper left-stop) (:right-bumper right-stop))
  (left-stop :stop (1 left-reverse))
  (right-stop :stop (1 right-reverse))
  (left-reverse :reverse (2 turn-right))
  (right-reverse :reverse (2 turn-left))
  (turn-right :turn-right (1 left-forward))
  (turn-left :turn-left (1 right-forward))
  (left-forward :forward ((:left-bumper :right-bumper) left-stop) (8 forward))
  (right-forward :forward ((:left-bumper :right-bumper) right-stop) (8 forward)))

Google Ads