Our objective is to measure all three lakes, once a lake is measured you can’t just drive over it. You risk getting a wheel trapped and getting stuck: an evasive action is necessary. You also can’t just drive back and return to roaming mode, this way you will risk detecting the same lake over and over again.
However, no lake is the same and you can only pass a lake at one side. To take this into account we wrote a program which makes an intelligent choice on what side to go past and make sure it clears the lake safely. Now the driving away is shown schematically in the pictures below, to see a bigger, more readable version you can click the pictures.

The marslander can either try going left or right to pass a lake. There is a chance that even with a good decision (in this case going right) a sensor (in this case: left) goes over the lake again, making it unsafe to drive on. To make sure it clears the lake the marslander: stops and backs up, steers left, then goes forward steering right, as can be seen in the above picture. We know we passed a lake if the sensors detect nothing for a certain time whilst driving away from the lake. Once we passed the lake, we return to roaming mode.
How does one choose the side to go? We decide to try and make a intelligent choice based on a history of sensor information. We count the number of times the left and right sensors are triggered during roaming to determine which way around our marslander is travelling on mars. If the left sensor is triggered the most, then we are travelling clockwise(see video in the post:roaming). This also holds true for the other way around.
Now we know which we around we are going, we know that most land is on the is on the side least triggered. In the case of a clockwise motion: the right. So our marslander will allways try going right first in this case. However it still is possible for our marslander to make a bad decision, we need to take this into account too. The action taken on a bad decision is shown schematiccaly below:

How do we tell we made a good or bad decision? We know there is not enough space between the lake and the edge on one side to go past. We determine if we chose the correct side by counting how long it’s been since our marslander has driven not detected any edges/lakes. If it detects something within this time frame(with the sensor furthest from the lake, in this case the left), we know we made the wrong choice, if it doesn’t we safely passed the lake and return to roaming mode. If we made the wrong choice we back up from the lake and try driving past the other side.
*A video of this in action will be posted soon!