  We consider Hamiltonians associated to optimal control problems for affine
systems on the torus. They are not coercive and are possibly unbounded from
below in the direction of the drift of the system. The main assumption is the
strong bracket generation condition on the vector fields. We first prove the
existence of a critical value of the Hamiltonian by means of the ergodic
approximation. Next we prove the existence of a possibly discontinuous
viscosity solution to the critical equation. We show that the long-time
behaviour of solutions to the evolutive Hamilton-Jacobi equation is described
in terms of the critical constant and a critical solution. As in the classical
weak KAM theory we find a fixed point of the Hamilton-Jacobi-Lax-Oleinik
semigroup, although possibly discontinuous. Finally we apply the existence and
properties of the critical value to the periodic homogenization of stationary
and evolutive H-J equations.
