Nonsmooth dynamics, bifurcation and control in an impact system