The ultrasonic sensor is located at the front of the robot and allows it to "see" its surroundings.
The gyroscope enables the robot to keep track of its rotation, and thereby allows it to make controlled turns.
Since the gyroscope is a little imprecise and therefore will accumulate a direction offset over time, the compass is used to recalibrate the direction of the robot.