[Thrun] And here is my solution. We have 4 cases.
On the left side, if I'm on the left side of the racecourse,
as defined that x is smaller to radius,
then my crosstrack_error is defined by the distance to the circle,
centered at radius comma radius minus the radius itself.
So this is going to be 0 if I'm exactly on the circle.
If I'm more than 3 times over to the right side, I get a circle again.
It looks like the one before, but now the center of the circle is a little bit further to the right
by 3 times radius as opposed to 1 radius.
The rest is identical to the line over here,
so I'm subtracting the same radius on the right side.
You can't quite see it but it's there.
Interesting are the straightaways.
So if my y value is large on the upper part of the diagram--
in fact, it's larger than radius--then my crosstrack_error is the y coordinate
times 2 times the radius, which is the height of the racetrack.
If I'm down at the bottom, it's just the y axis,
but really important is the minus sign because I'm moving in the opposite direction.
So for your code, to run this correctly you would have gotten everything in this routine right.
So that finishes my homework assignment.
Congratulations. You were able to make a car drive on a racetrack.
That is actually quite a significant component of making cars drive.
The PID control methodology that you learned today
and the smoothing methodology are really, really essential
not just in controlling self-driving cars but in a great number of other control setups.
Thank you for taking the class so far. You learned a lot already.
You learned about localization, about planning and control,
and we almost learned talking about how to build a self-driving car.