This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cs401r_w2016:lab8 [2018/03/07 18:30] sadler [Description:] |
cs401r_w2016:lab8 [2021/06/30 23:42] (current) |
||
---|---|---|---|
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> |