A geometric framework for dynamics with unilateral constraints and friction, illustrated by an example of self-organized locomotion. (30th April 2018)