  We study an elementary problem of topological robotics: rotation of a line,
which is fixed by a revolving joint at a base point: one wants to bring the
line from its initial position to a final position by a continuous motion in
the space. The final goal is to construct an algorithm which will perform this
task once the initial and final positions are given.
  Any such motion planning algorithm will have instabilities, which are caused
by topological reasons. A general approach to study instabilities of robot
motion was suggested recently by the first named author. With any
path-connected topological space X one associates a number TC(X), called the
topological complexity of X. This number is of fundamental importance for the
motion planning problem: TC(X) determines character of instabilities which have
all motion planning algorithms in X.
  In the present paper we study the topological complexity of real projective
spaces. In particular we compute TC(RP^n) for all n<24. Our main result is that
(for n distinct from 1, 3, 7) the problem of calculating of TC(RP^n) is
equivalent to finding the smallest k such that RP^n can be immersed into the
Euclidean space R^{k-1}.
