Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EG504N Take Home Exam / Assignment

Worth 15 % of overall grade

Topic: Localization - Particle Filter

Due date: Friday 11 November 2022 at 16:00

1    Assignment Instructions

• In the first function, draw samples from a zero-centered normal distribution by summing up 12 uniform distributed samples, as defined in the lecture.  To convert from a zero-centered distribution to another normal distribution, add the mean µ .

• Work on the assignment individually.

• A single typed document (submitted in PDF format) is expected.

• Show all steps / calculations / reasoning / references used.

• Include all Python code you commented or implemented in your report.

• Embed all the plots / code etc. in your answers at appropriate locations.

• Write your Name and Student Number clearly on the document

• Due by Deadline stated above. Any submission after this will be automatically treated as a Late Submis- sion and will be penalized as per the University Policy.

• Submit a single PDF document via MyAberdeen. File Name JDoeAssgt1.pdf for John Doe’s submission.

2    Q1 – Particle Filter

In this assignment you will implement in Python a complete particle filter. A code skeleton with the work flow of the particle filter is provided for you. A visualization of the state of the particle filter is also provided by the framework.

The following folders are included in the assignment framework.zip archive:

data  This folder contains files representing the world definition (i.e. landmarks) and sensor readings used by the filter.

code  This folder contains the particle filter framework with stubs for you to complete.

You can run the particle filter in the terminal:  python monte_carlo_localization .py.   It will not work properly until you completed the blanks in the code.

2.1

We used dictionaries to read in the sensor and landmark data.  Dictionaries provide an easier way to access data structs based on single or multiple keys. The read_sensor_data and read_world_data functions in the read_files .py file read the data from the files and create a dictionary for each of them with time stamps as the primary keys.

• Show understanding of the code of the two functions by commenting on the meaning of each line.

• Answer the following question: How many landmarks does world_data .dat contain and how many time stamps does sensor_data .dat contain?

2.2

Fill in the compute_importance_weights function and comment on the meaning of each line.  This function implements the measurement update step of a particle filter as presented in the lecture ”‘Probabilistic Sensor Models - 2”’, slide 20, using a range- only sensor. It takes as input positions lk  and observations zk  of landmarks. Note that individual observations are independent given a particle position xi  (see ”‘Probabilistic Sensor Models - 1”’, slide 30). The function returns a list of weights for the particle set. See slide 10 of the lecture ”‘Localization - Particle Filter - 2”’for the definition of weights wi .  Instead of calculating a probability, it is sufficient to calculate the likelihood p(z |x,l). Use the scipy .stats .norm .pdf function to evaluate this probability density function. The standard deviation of the normal distribution is σr  = 0.2.

Please also answer the following question: What is the value of the weight of the first particle drawn from the motion model?

2.3

Fill in the resampling function by implementing stochastic universal sampling as presented in the lecture ”‘Localization - Particle Filter - 3”’, slide 8.  Comment on the meaning of each line.  The function takes as an input a set of particles and the corresponding weights, and returns a sampled set of particles.  Use the numpy .random .uniform function to draw random number r.

Please also answer the following question: What is the value of the pose of the first resampled particle?

2.4

Use the plot_filter_state function to evaluate your completed particle filter implementation on the data provided in the folder data.  What is the value of the robot pose estimate for the time stamps 0, 5, and 10? Save the resulting visualizations of the particle filter state for the time stamps 0, 5, and 10 as PDF-files to your report.

3    Implementation Tips

For accessing the sensor data from the sensor readings dictionary, you can use

sensor_readings[timestamp,’sensor’][’id’]

sensor_readings[timestamp,’sensor’][’range]

sensor_readings[timestamp,’sensor’][’bearing]

and for odometry you can access the dictionary as

sensor_readings[timestamp,’odometry’][’r1’]

sensor_readings[timestamp,’odometry’][’t’]

sensor_readings[timestamp,’odometry’][’r2’]

For accessing the landmark positions from the landmarks dictionary, you can use

position_x = landmarks[id][0]

position_y = landmarks[id][1]

4    Report

Attach (or embed at appropriate location/s) the full, well-commented Python codes commented or implemented as well as the plots or visualizations obtained from Matplotlib used in completing the assignment.  Failing to do so will result in loss of points.

Note that this is 15% of your course grade. I am not expecting 50-page reports (more like 5 - 15)! But at the same time, make sure that you have included all the plots, codes, comments, steps and all the reasoning that is

required to adequately support what you have done.

Best of Luck!!