Control of a series of carts in the case of nonsmooth unilateral impacts