In this project, you will apply the skills you have acquired in this course to design a PID controller to perform vehicle trajectory tracking. Given a trajectory as an array of locations, and a simulation environment, you will design and code a PID controller and test its efficiency on the CARLA simulator used in the industry.
Run the following commands to install the starter code in the Udacity Workspace:
Clone the repository:
git clone https://github.com/udacity/nd013-c6-control-starter.git
Open new window
su - student
// Will say permission denied, ignore and continuecd /opt/carla-simulator/
SDL_VIDEODRIVER=offscreen ./CarlaUE4.sh -opengl
Open new window
cd nd013-c6-control-starter/project
./install-ubuntu.sh
cd pid_controller/
rm -rf rpclib
git clone https://github.com/rpclib/rpclib.git
cmake .
make
(This last command compiles your c++ code, run it after every change in your code)
To test your installation run the following commands.
cd nd013-c6-control-starter/project
./run_main_pid.sh
This will silently failctrl + C
to stop./run_main_pid.sh
(again) Go to desktop mode to see CARLA
If error bind is already in use, or address already being used
ps -aux | grep carla
kill id
In the previous project you built a path planner for the autonomous vehicle. Now you will build the steer and throttle controller so that the car follows the trajectory.
You will design and run the a PID controller as described in the previous course.
In the directory /pid_controller you will find the files pid.cpp and pid.h. This is where you will code your pid controller. The function pid is called in main.cpp.
Complete the TODO in the pid_controller.h and pid_controller.cpp.
Run the simulator and see in the desktop mode the car in the CARLA simulator. Take a screenshot and add it to your report. The car should not move in the simulation.
- In main.cpp, complete the TODO (step 2) to compute the error for the throttle pid. The error is the speed difference between the actual speed and the desired speed.
Useful variables:
- The last point of v_points vector contains the velocity computed by the path planner.
- velocity contains the actual velocity.
- The output of the controller should be inside [-1, 1].
-
Comment your code to explain why did you computed the error this way.
-
Tune the parameters of the pid until you get satisfying results (a perfect trajectory is not expected).
- In main.cpp, complete the TODO (step 3) to compute the error for the steer pid. The error is the angle difference between the actual steer and the desired steer to reach the planned position.
Useful variables:
- The variable y_points and x_point gives the desired trajectory planned by the path_planner.
- yaw gives the actual rotational angle of the car.
- The output of the controller should be inside [-1.2, 1.2].
- If needed, the position of the car is stored in the variables x_position, y_position and z_position
-
Comment your code to explain why did you computed the error this way.
-
Tune the parameters of the pid until you get satisfying results (a perfect trajectory is not expected).
The values of the error and the pid command are saved in thottle_data.txt and steer_data.txt. Plot the saved values using the command (in nd013-c6-control-refresh/project):
python3 plot_pid.py
You might need to install a few additional python modules:
pip3 install pandas
pip3 install matplotlib
summary you will apply the skills you have acquired in this course to design a PID controller to perform vehicle trajectory tracking. Given a trajectory as an array of locations, and a simulation environment, you will design and code a PID controller and test its efficiency on the CARLA simulator used in the industry.
PID (proportional integral derivative) controllers use a control loop feedback mechanism to control process variables. Manually tuning parameters by observing the simulated responses, the optimal values were found by trying first the P, then the I and then the D values one by one. In the simulation, the reactions of the vehicle were monitored.
What is the effect of the PID according to the plots, how each part of the PID affects the control command?
P represents the value reaching that value, D controls the rate at which it rises, and I catches subtle errors.
A program is needed to calculate the rate of growth for reached values
Manual adjustment begins by setting the integral and differential values to zero. The rate increases until the controller starts to oscillate. Test and adjust the stability of the PID controller to achieve the appropriate response time. Automatic tuning eliminates manual tuning trial and error. Automatically adjust the PID parameters using the control loop or the Twiddle algorithm. Twiddle is an algorithm that tries to find a parameter p suitable for Algorithm A that returns an error. When the twiddle variable is set to true, the simulator runs the vehicle confidently through the twiddle algorithm until the maximum phase initially set continues. After each iteration of the race, the simulator is reset to the initial stage from the start until the maximum stage is reached.
PID controller is a model free controller, i.e. it does not use a model of the car. Could you explain the pros and cons of this type of controller? Find at least 2 pros and cons for model free versus model based.
PID gain can be designed just based on the system tracking error.
The controller generally has to balance