We present an experimental realization of the collective trapping phase transition [Kaiser et al., Phys. Rev. Lett. 108, 268307 (2012)], using motile polar granular rods in the presence of a V-shaped obstacle. We offer a theory of this transition based on the interplay of motility-induced condensation and liquid-crystalline ordering and show that trapping occurs when persistent influx overcomes the collective expulsion of smectic defect structures. In agreement with the theory, our experiments find that a trap fills to the brim when the trap angle theta is below a threshold theta(c), while all particles escape for theta > theta(c). Our simulations support a further prediction, that B e goes down with increasing rotational noise. We exploit the sensitivity of trapping to the persistence of directed motion to sort particles based on the statistical properties of their activity.