Here I provide a simple but highly accurate trajectory(lateral) control method for self-driving cars. The simulation is based on the CarlaSimulator /Game/Maps/RaceTrack, where you can follow the Coursera's Self-driving Specialization course-1 final project to setup.
The overview of the result without careful tuning is shown below. The controlled trajectory(orange line) perfectly overlaps on the desired/reference trajectory(green line).
Zoom in 400% for the details in the turns/arcs:
The core idea is the dynamic lookahead length based on a lookahead time(around 0.5s) and current velocity for the "next waypoint", rather than a fixed lookahead length. Then use the Stanley method as the course suggests. The pursuit method should also work.
As for the longitudinal control, it's just a simple PID controller as the course suggests, additionally I defined a simple smoother for throttle control for comfort consideration. Therefore it doesn't follow the desired/reference velocity so well at the velocity spikes, as shown below, blue line is the desired velocity: