In the first case, the robot hits the wall, and 'realises' this (probably through a microphone mounted at the front of the machine) then reverses its motor and turns away. Yet from the second case onwards, the robot must determine its distance from the wall, and must turn to avoid collision. From the third instance, shape-detection is necessary. The robot must carry a camera, or similar optical device, and it must be able to detect edges and shapes. The fourth case includes colour recognition on top of this.
Application of AI to Robotics?
One of the main applications of AI is in the area of robot control. By using evolving control architectures, the robot can 'learn' the best way to do a task. Designers can use neural networks and genetic algorithms to enable the robot to cope with complicated tasks, such as navigation in a complicated environment (Mars, for instance). Another area is image, sound and pattern recognition - 3 traits that any anthropomorphic robot would need. Again, neural-networks could be used to analyze data from the optical or audio device the robot used.
Example
A robot is assigned to hover over an assembly line and examine the gears that pass underneath is for faults. If a fault is discovered, the robot is to push the gear off the line into the rejection bin. Before the robot is put into practice, the robot is trained using a neural network to recognize the salient features of the gear - its radius, the shape of its perimeter, and its size. When the machine is then put on to the assembly line, its optical equipment converts what it sees into input for the neural network which then analyzes whether the gear is ok or not. If so, it passes, else an arm is activated to push the gear off. There are limitations to such visual systems, described in the Problems with Machine Vision essay.
Another area that robotics and AI/ALife are closely connected is the 'simple function, complex behaviour' robots. Such robots perform small tasks, using very simple rules, but behave rather in a complicated fashion, in a very similar way to Conway's Boids. For example, 5-6 robots could be programmed to clean up a room, moving small objects to the nearest corner of the room, whilst avoiding obstacles and each other. The military and NASA are researching such robots as possible spy (or for NASA, exploration) robots that could easily pass through enemy defenses, and through sheer numbers gather a large amount of data, without risk of loss of human life.
Conclusion.
Robotics is in many respects Mechanical AI. It is also a lot more complicated, since the data the robot is receiving is real-time, real-world data, a lot more complicated that more software-based AI programs have to deal with. On top of this more complicated programming required, algorithms to respond via motors and other sensors is needed.
The field of robotics is where AI is all eventually aimed, most research is intended to one day become part of a robot.