Many insects can navigate accurately using the polarized light from the sky. A study of a large number of experiments on the behaviour and anatomy of insects has led to a simple algorithm for navigation by skylight, suitable for a robot or drone in lightly clouded skies. The algorithm is based on the special ability of insect eyes to measure the position of the 4 points in the sky at which the polarization angle, i.e. the angle X between the polarized E-vector and the meridian, equals +/-pi/4. The azimuths of these 4 points are possibly the only measurable quantities that are invariant to variable cloud cover, provided that polarized light is still detectable below the clouds. It is shown that the sum of these 4 azimuths can be turned into a celestial compass in a few short steps. A simulation shows that the compass is accurate as well as simple and well suited for a robot or drone. It can also explain many of the experimental results published on insect navigation.