Detecting the type of surface/medium a robot is on top of
Those three different types of ground (grass, sand and tarmac) will be predominantly three different colours - green, yellow and black. Simple light sensors and appropriate colour filters might work.

I just remembered an aid for the blind that was developed many years ago, based on sonar. The person swept the sound source backwards and forwards in front of him or her, and was able to detect obstacles from the returned signal. It was possible for different textures to be detected, such as grass and leaves. I looked up sonar and texture on Google and found this. It looks as though the technique is suitable for detecting terrain.

Both techniques could be used, with some form of sensor fusion, to maximise the probability of a correct identification.