Control of Nonholonomic Systems: from Sub-Riemannian Geometry to Motion Planning