Control of a class of nonsmooth dynamical systems