We implemented a wall following algorithm which calculates the distance of the wall. If we know the distance of the wall, we can compare it with the desire distance and calculate the trajectory. We wrote two files: dist_finder.py and control.py.
Distfinder.py determines how far the car is from the wall. We wrote two methods in here called getRange and callback. These were fairly easy to write because of our past experience with ROS. This node subscribes to the LIDAR and publishes to the topic error.
There were originally some struggles getting this to work as you can see below:
However, after tuning the various parameters like Kp, Kd, distance from the wall, projection distance, we were able to get our car working pretty well! We also decided to implement PID steering which involves the car changing speed based on where it is on the track. When on the straights, the car will move a lot faster and then slow down while making a turn. And if the error is a certain amount below the threshold, we maximize speed. We hoped this strategy would shave off some time during the race. What actually made the car move much faster and shaved off a whole second of our laptime was having it follow the center line on the track. Here is our car after this successful implementation!