As well as micro switches mounted on the corners of the robot, I'm using an ultrasonic distance sensor .