[Thrun] So in this next assignment, I'd like you to fix certain data points.
Just as much as you fixed the data points originally in our path,
the beginning and end point, now I want to fix you 4 points.
These are the corner points in our data points.
In our original data, it's the one over here, the one over here,
and I want those to be fixed so they can't move.
And the way I indicated this in the code is by giving you a fix array that looks like this
where each of these numbers corresponds to exactly 1 data point.
There's as many elements in fix as there is in path.
And then when I call smooth, I add fix as a parameter.
So when you change the procedure and run it,
I can tell you you should be surprised by the output
in that when I run my procedure it copies over the initial path into the output.
We'll talk about this in a second, but please go ahead and change your procedure
so that your output ends up to be giving you something very much like this.
The modification is simple.
As I go through my data points, I only apply the update if it's not fixed.
So if the fix flag is not set, they go in here.
This is all indented one compared to before.
It's a single line change.
Let me tell you why this doesn't work.
Consider a few data points like these.
If you fix this data point over here,
then this guy is perfectly happy with his 2 neighbors--
this is a smooth path--
and so is this guy over here.
The only data point that's unhappy is the one over here
because it's not part of a very smooth path,
but this one is never being updated.
So as a result, all the other ones stay where they are.
They already have the absolute minimum for smoothness and for the data fit.
No updates take change, and we don't have the desired result.
We don't get a nice round curve the way we wish to get it.
To get this, we are going to modify our rule a little bit now, and that's the interesting part.
For a node like this with coordinates xi and yi,
we add to it with a very small constant gamma--
in fact, it will be half our weight smoothing constant in a minute--
2 times the previous guy--
and of course that's cyclic, so you have to make sure this is really cyclic--
minus the guy 2 steps away and minus our node.
Why this makes sense we see when we go into the opposite direction.
Here we add a small gamma, 2 times this guy over here minus this guy here
minus our original data point.
And behind this is a certain desire.
We want the vector over here to be the same as the vector over here.
This vector is this difference over here of xi + 1 over yi + 1 - xi over yi.
That is this vector over here.
And the vector over here is similarly the difference of the point i + 2
minus the same for i + 1.
If you set these to be equal and bring yi to the right side,
then if you modify yi in proportion to this expression over here, we reduce the error.
In fact, the expression in the brackets is the same as this one, called (A),
minus this one, called (B).
So we're looking at the mismatch between these 2 vectors
and use it to adjust the xi factor over here.
We do those sequentially--this one first, this one second.
You might call them a little bit sloppy
because the first update already inferences the second update. But who cares?
We're just going to add lines of code that achieve this over here,
and when you do this, please make sure that your update
understands the fact that these indices are cyclic.
So I did this in my code and I'm running it,
and out come the following numbers that you can read over here.
These numbers are indeed a cycle.
So if we were to plot them--and this is the original data--
these are the points we would constant,
then the new data lies in over very much like this. You can plot them.
Unfortunately, I can't plot them in our environment here, but you could see this.
Now we are not shifting the racetrack inbound anymore.
Please go to your code and modify the function smooth by doing these new constraints.
For the update strength, I suggest you use half of weight_smooth for each update.
So in total, you add another 0.1 as update strength.