The purpose of the Trapped Behaviour is to try and detect a impending situation where the robot will run into a place it cannot get out of with out either colliding with something or having to make a laboured turn around.
The Trapped Behaviour monitors all the forward and side facing sonar's and determines how many of them are below the sonar object near value (This limit is the one where the robot slows down a little to help the sensors detect and object correctly). If 6 of the 7 monitored sensors detect an object/s below the near value then it will activate and get the robot to turn 180 degrees, therefore heading away from the trapped area.