List of commits:
Subject Hash Author Date (UTC)
Dennis Wagners work 1c13a0f9f68878d43b2721dea5d85520addff374 B.Sc. Moczalla, Rafael 2017-05-27 11:07:40
README added 1ebabdde437e516282d5984ab46e24696ca5b5f8 B.Sc. Moczalla, Rafael 2017-05-25 11:54:21
first push 69514078177c368ef34ebcb0ea20f3cc853dd78e B.Sc. Moczalla, Rafael 2017-05-25 11:29:50
Commit 1c13a0f9f68878d43b2721dea5d85520addff374 - Dennis Wagners work
Author: B.Sc. Moczalla, Rafael
Author date (UTC): 2017-05-27 11:07
Committer name: B.Sc. Moczalla, Rafael
Committer date (UTC): 2017-05-27 11:07
Parent(s): 1ebabdde437e516282d5984ab46e24696ca5b5f8
Signing key:
Tree: 01376be9b66b91981914c188b410844e37b795e9
File Lines added Lines deleted
draw.pyc 0 0
particle_filter.py 52 7
File draw.pyc changed (mode: 100644) (index 7581e7a..87981b3)
File particle_filter.py changed (mode: 100644) (index 2856bfb..b2a5ae5)
... ... while True:
176 176 # Read Robot's sensor # Read Robot's sensor
177 177 r_d = nao.read_sensor(world) r_d = nao.read_sensor(world)
178 178
179 # TODO: Update particle weight according to how good every particle matches
180 # sensorupdate()
179 # Aufgabe 3.1: sensor update
180 # Update particle weight according to how good every particle matches
181 #for p in particles:
182 # p.w = ...
183
184 for p in particles:
185 p.w = w_gauss(p.read_sensor(world), r_d)
181 186
182 187 # ---------- Show current state ---------- # ---------- Show current state ----------
183 188 world.show_particles(particles) world.show_particles(particles)
 
... ... while True:
187 192 # ---------- Shuffle particles ---------- # ---------- Shuffle particles ----------
188 193 new_particles = [] new_particles = []
189 194
190 # TODO: Normalise weights
191 # normalize() # fuer Resampling
195 # Aufgabe 3.2: resampling
196 # calculate new samples (new_particles) based on the weigths (p.w) of the old partiucles
197 # Example: Stochastic universal sampling
198 # https://en.wikipedia.org/wiki/Stochastic_universal_sampling
199
200 # The index of the current particle
201 current_particle_index = 0
202
203 # Delta of equidistant slices of weights
204 dp = sum([p.w for p in particles])/len(particles)
205
206 # Offset from where to start
207 offset = random.uniform(0, dp)
208
209 # The distance in weight space for the new particle: offset + i*dp
210 new_part_weitgh_d = offset
211
212 weight_sum = 0
213
214 new_particles = []
215
216 # Loop over all particles
217 for i in range(len(particles)):
218
219 # Add up weights of particles until first time larger than offset + i*dp
220 while weight_sum + particles[current_particle_index].w <= new_part_weitgh_d:
221 weight_sum += particles[current_particle_index].w
222 current_particle_index += 1
223
224 # The particle around which to saple a new particle
225 p = particles[current_particle_index-1]
226
227 # Sample the new particle with some noise and increment the sum for the next particle
228 x, y = add_little_noise(*p.xy)
229
230 # Resample particle with increasing noise to avoid sampling points inside a wall or outside world
231 c = 2
232 while not world.is_free(x, y):
233 x, y = add_noise(c*0.02, *p.xy)
234 c += 1
235
236 new_particles.append(Particle(x, y, p.h, p.w, True))
237 new_part_weitgh_d += dp
192 238
193 # TODO: update Samples
194 # resample()
239 particles = new_particles
195 240
196 241 # ---------- Move things ---------- # ---------- Move things ----------
197 242 old_heading = nao.h old_heading = nao.h
 
... ... while True:
201 246 # Move particles according to my belief of movement # Move particles according to my belief of movement
202 247 for p in particles: for p in particles:
203 248 p.h += d_h # in case robot changed heading, swirl particle heading too p.h += d_h # in case robot changed heading, swirl particle heading too
204 p.advance_by(nao.speed)
249 p.advance_by(nao.speed, checker=lambda r, dx, dy: world.is_free(r.x+dx, r.y+dy))
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/bscmoczallarafael/kogrob-ha03

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/bscmoczallarafael/kogrob-ha03

Clone this repository using git:
git clone git://git.rocketgit.com/user/bscmoczallarafael/kogrob-ha03

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main