Skip to content

Commit

Permalink
End of year
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Evans committed Dec 1, 2023
1 parent 0ee0227 commit 5b674ce
Show file tree
Hide file tree
Showing 4 changed files with 660 additions and 658 deletions.
1,294 changes: 643 additions & 651 deletions media/Particle Filter localisation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions sensor_fusion/RacingTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def simulate_car_pf():

true_states, noisy_states = robot.get_states()
estimates = particle_filter.get_estimated_states()
plot_racing_localistion(estimates, true_states, noisy_states, robot)

mae = np.mean(np.abs(true_states - estimates))
print(f"MAE: {mae:.4f} cm")
plot_racing_localistion(estimates, true_states, noisy_states, robot)



def profile_particle_filter(number_of_particles):
Expand Down
17 changes: 13 additions & 4 deletions sensor_fusion/estimators/ParticleFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@ def control_update(self, control):
random_samples = np.random.multivariate_normal(np.zeros(3), self.Q, self.NP)
self.particles = next_states + random_samples

def particle_control_update(self, control):
next_states = self.f(self.particles, control)
random_samples = np.random.multivariate_normal(np.zeros(3), self.Q, self.NP)
self.particles = next_states + random_samples
# def particle_control_update(self, control):
# next_states = self.f(self.particles, control)
# random_samples = np.random.multivariate_normal(np.zeros(3), self.Q, self.NP)
# self.particles = next_states + random_samples

def measurement_update(self, measurement):
particle_measurements = self.h(self.particles)
z = particle_measurements - measurement
# ssd = np.power(z, 2)
# ssd = np.sum(ssd, axis=1)
# sigma = np.sqrt(np.average(ssd, axis=0))
# self.weights = 1.0 / np.sqrt(2.0 * np.pi * sigma ** 2) * np.exp(-ssd / (2 * sigma ** 2))


# ssd = np.power(z, 2)
# ssd = np.sum(ssd, axis=1)
# self.weights = np.exp(-0.5 * ssd)
sigma = np.sqrt(np.average(z**2, axis=0))
weights = 1.0 / np.sqrt(2.0 * np.pi * sigma ** 2) * np.exp(-z ** 2 / (2 * sigma ** 2))
self.weights = np.prod(weights, axis=1)
Expand Down
3 changes: 2 additions & 1 deletion sensor_fusion/robots/AutonomousRacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
RANGE = 100

MAP_NAME = "aut_wide"
NUM_BEAMS = 10
NUM_BEAMS = 200
# NUM_BEAMS = 45


class AutonomousRacer:
Expand Down

0 comments on commit 5b674ce

Please sign in to comment.