|
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | 5 | "execution_count": null, |
6 | | - "id": "3c012c2f", |
| 6 | + "id": "1a559689", |
7 | 7 | "metadata": { |
8 | 8 | "deletable": false, |
9 | 9 | "editable": false |
|
115 | 115 | "plt.show()" |
116 | 116 | ] |
117 | 117 | }, |
| 118 | + { |
| 119 | + "cell_type": "markdown", |
| 120 | + "id": "69404554", |
| 121 | + "metadata": { |
| 122 | + "tags": [ |
| 123 | + "otter_answer_cell" |
| 124 | + ] |
| 125 | + }, |
| 126 | + "source": [ |
| 127 | + "## Part 1, continued\n", |
| 128 | + "\n", |
| 129 | + "Now that we have this line, we need to make it work as input to our state space system. While the real world is continuous, computers are discrete. Computers evaluate the system at specific time points, with specific-sized time steps. If the time steps are too small, the simulation will be more accurate (capturing all of the contours of the road), but will take a very long time to complete. If the time steps are too big, the simulation will be fast, but inaccurate -- it might miss an important road feature.\n", |
| 130 | + "\n", |
| 131 | + "We can explore this phenomenon by evaluating our bump with different sized time steps. We will use Numpy's `np.interp` function to interpolate the line at specific time points.\n", |
| 132 | + "\n", |
| 133 | + "Let's first interpolate the line every 10ms." |
| 134 | + ] |
| 135 | + }, |
118 | 136 | { |
119 | 137 | "cell_type": "code", |
120 | 138 | "execution_count": null, |
|
157 | 175 | }, |
158 | 176 | { |
159 | 177 | "cell_type": "markdown", |
160 | | - "id": "a4ff0a87", |
161 | | - "metadata": {}, |
| 178 | + "id": "28a12705", |
| 179 | + "metadata": { |
| 180 | + "tags": [ |
| 181 | + "otter_answer_cell" |
| 182 | + ] |
| 183 | + }, |
162 | 184 | "source": [ |
163 | | - "## Part 1, cont.\n", |
164 | | - "Now that we have this line, we need to make it work as input to our state space system. While the real world is continuous, computers are discrete. Computers evaluate the system at specific time points, with specific-sized time steps. If the time steps are too small, the simulation will be more accurate (capturing all of the contours of the road), but will take a very long time to complete. If the time steps are too big, the simulation will be fast, but inaccurate -- it might miss an important road feature.\n", |
165 | | - "\n", |
166 | | - "We can explore this phenomenon by evaluating our bump with different sized time steps. We will use Numpy's `np.interp` function to interpolate the line at specific time points.\n", |
| 185 | + "## Part 1, cont\n", |
| 186 | + "With `dt` set to `10ms`, the interpolated road still looks like our road. But what happens if `dt` is too large?\n", |
167 | 187 | "\n", |
168 | | - "Let's first interpolate the line every 10ms." |
| 188 | + "Let's first define a function to interpolate a line with a given car `velocity` and `dt` so we can experiment easily with different `dt` values." |
169 | 189 | ] |
170 | 190 | }, |
171 | 191 | { |
|
211 | 231 | "plt.show()" |
212 | 232 | ] |
213 | 233 | }, |
214 | | - { |
215 | | - "cell_type": "markdown", |
216 | | - "id": "fc98cd4c", |
217 | | - "metadata": {}, |
218 | | - "source": [ |
219 | | - "## Part 1, cont\n", |
220 | | - "With `dt` set to `10ms`, the interpolated road still looks like our road. But what happens if `dt` is too large?\n", |
221 | | - "\n", |
222 | | - "Let's first define a function to interpolate a line with a given car `velocity` and `dt` so we can experiment easily with different `dt` values." |
223 | | - ] |
224 | | - }, |
225 | 234 | { |
226 | 235 | "cell_type": "code", |
227 | 236 | "execution_count": null, |
228 | | - "id": "e36ca00c", |
| 237 | + "id": "aeecb898", |
229 | 238 | "metadata": { |
230 | 239 | "deletable": false, |
231 | 240 | "editable": false |
|
239 | 248 | "cell_type": "markdown", |
240 | 249 | "id": "17c77e46", |
241 | 250 | "metadata": { |
242 | | - "deletable": false, |
243 | | - "editable": false |
| 251 | + "tags": [ |
| 252 | + "otter_answer_cell" |
| 253 | + ] |
244 | 254 | }, |
245 | 255 | "source": [ |
246 | 256 | "Now, use `interpolate_road` to find a `dt` where the bump in the road disappears. Graph your results." |
|
279 | 289 | { |
280 | 290 | "cell_type": "code", |
281 | 291 | "execution_count": null, |
282 | | - "id": "abcd309d", |
| 292 | + "id": "62e43826", |
283 | 293 | "metadata": { |
284 | 294 | "deletable": false, |
285 | 295 | "editable": false |
|
293 | 303 | "cell_type": "markdown", |
294 | 304 | "id": "45df6b1f", |
295 | 305 | "metadata": { |
296 | | - "deletable": false, |
297 | | - "editable": false |
| 306 | + "tags": [ |
| 307 | + "otter_answer_cell" |
| 308 | + ] |
298 | 309 | }, |
299 | 310 | "source": [ |
300 | 311 | "## Part 2: The state space model for a quarter car\n", |
|
308 | 319 | "cell_type": "markdown", |
309 | 320 | "id": "73e41a58", |
310 | 321 | "metadata": { |
311 | | - "deletable": false, |
312 | | - "editable": false |
| 322 | + "tags": [ |
| 323 | + "otter_answer_cell" |
| 324 | + ] |
313 | 325 | }, |
314 | 326 | "source": [ |
315 | 327 | "\n", |
|
485 | 497 | "cell_type": "markdown", |
486 | 498 | "id": "ebff6274", |
487 | 499 | "metadata": { |
488 | | - "deletable": false, |
489 | | - "editable": false |
| 500 | + "tags": [ |
| 501 | + "otter_answer_cell" |
| 502 | + ] |
490 | 503 | }, |
491 | 504 | "source": [ |
492 | 505 | "### Translating the state space model into Python\n", |
|
674 | 687 | { |
675 | 688 | "cell_type": "code", |
676 | 689 | "execution_count": null, |
677 | | - "id": "88f06b9d", |
| 690 | + "id": "45c400e3", |
678 | 691 | "metadata": { |
679 | 692 | "deletable": false, |
680 | 693 | "editable": false |
|
700 | 713 | "First, let's generalize the animation function so that you can easily animate new cars." |
701 | 714 | ] |
702 | 715 | }, |
703 | | - { |
704 | | - "cell_type": "markdown", |
705 | | - "id": "47098ab4", |
706 | | - "metadata": { |
707 | | - "tags": [ |
708 | | - "otter_answer_cell" |
709 | | - ] |
710 | | - }, |
711 | | - "source": [ |
712 | | - "_Type your answer here, replacing this text._" |
713 | | - ] |
714 | | - }, |
715 | 716 | { |
716 | 717 | "cell_type": "code", |
717 | 718 | "execution_count": null, |
|
771 | 772 | }, |
772 | 773 | "outputs": [], |
773 | 774 | "source": [ |
774 | | - "# GUIDE: Animate car with the large timestamp that misses the bump." |
| 775 | + "# Next, let's try simulating the same quarter car on the same road, \n", |
| 776 | + "# but with the large `dt` value that you used previously. \n", |
| 777 | + "# You will notice that the car does not react to the bump because the simulation did not \"see\" the bump!\n", |
| 778 | + "# \n", |
| 779 | + "# GUIDE: Animate car with the large timestamp that misses the bump.\n", |
| 780 | + "..." |
775 | 781 | ] |
776 | 782 | }, |
777 | 783 | { |
|
785 | 791 | }, |
786 | 792 | "outputs": [], |
787 | 793 | "source": [ |
788 | | - "# GUIDE: animate car with a small timestamp." |
| 794 | + "# Now, let's try the same simulation, but make `dt` very small. \n", |
| 795 | + "# What ends up happening? Does your animation complete?\n", |
| 796 | + "# \n", |
| 797 | + "# GUIDE: animate car with a small timestamp.\n", |
| 798 | + "..." |
789 | 799 | ] |
790 | 800 | }, |
791 | 801 | { |
|
909 | 919 | { |
910 | 920 | "cell_type": "code", |
911 | 921 | "execution_count": null, |
912 | | - "id": "d9812252", |
| 922 | + "id": "96dec755", |
913 | 923 | "metadata": { |
914 | 924 | "deletable": false, |
915 | 925 | "editable": false |
|
0 commit comments