Conversation
| self.map = None | ||
| self.num_particles = NUM_PARTICLES | ||
| self.particle_paths = {} | ||
| self.particle_observations = {} |
There was a problem hiding this comment.
It might be a good idea to make all particles share a single observation history to save space. Also, if each particle has its own path and observation history, then that should be an attribute of the Particle class, not the node. Storing all of their paths/observations in a single node variable could make multi-threading a headache.
| scale = random.uniform(0.8, 1.2) | ||
| noisy_dx *= scale | ||
| noisy_dy *= scale | ||
| offset_magnitude = 0.05 |
There was a problem hiding this comment.
Make this a global constant at the top of the file pls
| resolution = self.map['resolution'] | ||
| col = int(particle.x / resolution) | ||
| row = int(particle.y / resolution) | ||
| if 0 <= row < self.map['height'] and 0 <= col < self.map['width']: |
There was a problem hiding this comment.
This is already assumed from the if statement on line 249 that checks for out-of-bounds particles
| map_width_m = self.map['width'] * resolution | ||
| map_height_m = self.map['height'] * resolution | ||
| if particle.x < 0 or particle.x >= map_width_m or particle.y < 0 or particle.y >= map_height_m: | ||
| particle.x = random.uniform(0, map_width_m) |
There was a problem hiding this comment.
Why are out-of-bounds particles sent to a random position after moving them? The resampling phase should take care of them by giving them a terrible weight. Resetting their observations also decouples their observations from the rest of the particles
| def resample_particles(self): | ||
| if not self.particles: | ||
| return | ||
| if self.map is None: |
There was a problem hiding this comment.
This should never happen. Throwing an error would be more appropriate than continuing.
| noise_y = random.gauss(0.0, RESAMPLE_NOISE_STD_DEV) | ||
| new_x = old_particle.x + noise_x | ||
| new_y = old_particle.y + noise_y | ||
| if new_x < 0 or new_x >= map_width_m or new_y < 0 or new_y >= map_height_m: |
There was a problem hiding this comment.
instead of this, can you clamp the new_x and new_y to the map boundaries?
| self.resample_particles() | ||
| self.publish_estimated_pose() | ||
|
|
||
| def eliminate_low_weight_particles(self): |
There was a problem hiding this comment.
I don't understand the purpose of this, shouldn't normal resampling take care of eliminating low-weight particles?
| marker_array.markers.append(line_marker) | ||
| self.observations_pub.publish(marker_array) | ||
|
|
||
| def apply_jitter(self): |
There was a problem hiding this comment.
Explain what problem this solves pls
No description provided.