In this project, I implemented a longitudinal PID and lateral Stanley controller to drive an ego vehicle around a given set of waypoints in the Carla simulator.
The PID controller simulates the following model:
where Kp, Ki, and Kd are the proportional, integral, and derivative gains, respectively. The error term is defined as the difference between the desired velocity and the current velocity: e (t) = v_desired (t) - v (t). The output of the controller is the throttle input for the subsequent timestep, defined as a percentage between 0.0 and 1.0. Finally, I manually tuned the PID controller considering the following behaviors from independently manipulating each of the constant gains:
The Stanley controller is employed to output approrpriate steering commands that keep the ego vehicle on its expected path. The Stanley method uses the center front axle of the vehicle as its reference point and the follow kinematic model:
where δ is the steering angle, e is the crosstrack error, and ψ is the heading error.