When the car in the video sees something straight ahead, it turns the sonar 90 degrees to left, then it turns itself 90 degrees to right. Then it tries to drive having the obstacle at a constant distance at the left. When the obstacle disappears, the car turns to the left until the obstacle reappear to the car's left. This goes on until there's a line to follow again. At that point the car obviously has to turn to the right to follow the line again.
If this is a school assignment, I bet you have got it months ago. Surely your teacher can't expect you to just google and find suitable code from somewhere. You can rebuild a well documented project without understanding the code, but you can't adapt code to your own project without understanding the code.