Skip to content

chris code#1

Open
jColbor wants to merge 4 commits into
mainfrom
chris-dev
Open

chris code#1
jColbor wants to merge 4 commits into
mainfrom
chris-dev

Conversation

@jColbor
Copy link
Copy Markdown
Owner

@jColbor jColbor commented Dec 1, 2025

No description provided.

self.map = None
self.num_particles = NUM_PARTICLES
self.particle_paths = {}
self.particle_observations = {}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']:
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what problem this solves pls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants