Energy-Optimal Braking Control Using a Double-Layer Scheme for Trajectory Planning and Tracking of Connected Electric Vehicles