User Tools

Site Tools


cs401r_w2016:lab8

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs401r_w2016:lab8 [2018/03/05 17:44]
sadler [Description:]
cs401r_w2016:lab8 [2021/06/30 23:42] (current)
Line 37: Line 37:
 ====Description:​==== ====Description:​====
  
-For this lab, you will implement the basic particle filter found in Algorithm 23.1 of the book (pg. 826).  You can assume that your particle proposal distribution is equal to the dynamics prior (see Section 23.5.4), which leads to a very simple form of particle filtering. ​ Specifically,​ you may assume that the "​dynamics"​ are that the moves in a random direction and changes angles randomly. ​ I used $p(z_{t+1}|z_{t}) = \mathcal{N}(0,\Sigma)$, where $\Sigma$ is a parameter you will need to tune.+For this lab, you will implement the basic particle filter found in Algorithm 23.1 of the book (pg. 826).  You can assume that your particle proposal distribution is equal to the dynamics prior (see Section 23.5.4), which leads to a very simple form of particle filtering. ​ Specifically,​ you may assume that the "​dynamics"​ are that the moves in a random direction and changes angles randomly. ​ I used $p(z_{t+1}|z_{t}) = \mathcal{N}(z_{t},\Sigma)$, where $\Sigma$ is a parameter you will need to tune.
  
 You will need the following files: You will need the following files:
Line 63: Line 63:
 Your proposal distribution can be anything you want.  Be creative. ​ You may have to experiment! Your proposal distribution can be anything you want.  Be creative. ​ You may have to experiment!
  
-You should experiment with two different likelihoods. ​ First, try using a simple Gaussian likelihood. ​ You will need to tune the variance, but don't spend too long on it; I never got this to work very well.  Second, try using a simple Laplacian distribution. ​ (The Laplacian is like a Gaussian, except that instead of squaring the difference, one uses an absolute value): $$p(y_t|z_t^s) = \exp \left( -\sigma \sum_i \lvert (y_t)_i - \mathrm{cast\_rays}(z_t^s)_i \rvert \right)$$, where $\sigma$ is a parameter that you will need to tune.+You should experiment with two different likelihoods. ​ First, try using a simple Gaussian likelihood. ​ You will need to tune the variance, but don't spend too long on it; I never got this to work very well.  Second, try using a simple Laplacian distribution. ​ (The Laplacian is like a Gaussian, except that instead of squaring the difference, one uses an absolute value): $$p(y_t|z_t^s) = \exp \left( -\dfrac{1}{\sigma\sum_i \lvert (y_t)_i - \mathrm{cast\_rays}(z_t^s)_i \rvert \right)$$, where $\sigma$ is a parameter that you will need to tune.
  
 You will have to experiment with the parameters of these distributions to make them work.  Try values between 0.01 and 1. You will have to experiment with the parameters of these distributions to make them work.  Try values between 0.01 and 1.
Line 115: Line 115:
  
 The combination of these two things allowed me to experiment with my particle filter in real-time. ​ Note that you are not required to produce any sort of visualization over time, just a single plot at the end of running your code.  The use of ''​pyqtgraph''​ is strictly for the work you will do debugging your particle filter. The combination of these two things allowed me to experiment with my particle filter in real-time. ​ Note that you are not required to produce any sort of visualization over time, just a single plot at the end of running your code.  The use of ''​pyqtgraph''​ is strictly for the work you will do debugging your particle filter.
 +
 +Or if you want to use matplotLib which is better for Jupyter Notebook but slower, here is some code for plotting at each iteration:
 +<code python>
 +import matplotlib.pyplot
 +import numpy
 +from IPython.display import clear_output
 +
 +def draw(particles,​ true_values,​ predicted_values,​ t):
 +    clear_output(wait=True)
 +    show_map( room_map )
 +    plt.scatter(particles[0,:​] , particles[1,:​],​ c="​yellow"​)
 +    plt.plot(true_values[0,:​t+1], ​ true_values[1,:​t+1] , c= "​green",​ label="​Actual Position"​)
 +    plt.plot(predicted_values[0,:​t+1],​ predicted_values[1,:​t+1],​ c= "​red",​ label="​Estimated Position"​)
 +    plt.legend(loc=1)
 +    plt.show()
 +</​code>​
cs401r_w2016/lab8.1520271872.txt.gz ยท Last modified: 2021/06/30 23:40 (external edit)