A solution of the minimum-time speed planning problem based on lattice theory