@Test public void testUpdateSensor() { double wifiX = 1.f; double wifiY = 5.f; pf = new ParticleFilterTestable(); pf.setNumParticles(2); Particle tmp = new Particle(2.f, 4.f, 0.5f); pf.particleList.add(tmp); tmp = new Particle(20.f, 40.f, 0.5f); pf.particleList.add(tmp); pf.updateSensor(wifiX, wifiY); assertEquals(0.966f, pf.particleList.get(0).getWeight(), 0.01f); assertEquals(0.034f, pf.particleList.get(1).getWeight(), 0.01f); }
public void updateSensor(double x, double y) { float normalize = 0.f; for (int i = 0; i < numParticles; i++) { final double sqrX = (x - particleList.get(i).getX()) * (x - particleList.get(i).getX()); final double sqrY = (y - particleList.get(i).getY()) * (y - particleList.get(i).getY()); double sqrt = Math.sqrt(sqrX + sqrY); if (sqrt == 0.f) { sqrt = 0.000001f; } final double dist = 1.f/sqrt; final double weight = dist; particleList.get(i).setWeight(weight); normalize += weight; } normalizeWeights(normalize); }
ParticleFilter { public void updateSensor(double x, double y) { float normalize = 0.f; for (int i = 0; i < numParticles; i++) { final double sqrX = (x - particleList.get(i).getX()) * (x - particleList.get(i).getX()); final double sqrY = (y - particleList.get(i).getY()) * (y - particleList.get(i).getY()); double sqrt = Math.sqrt(sqrX + sqrY); if (sqrt == 0.f) { sqrt = 0.000001f; } final double dist = 1.f/sqrt; final double weight = dist; particleList.get(i).setWeight(weight); normalize += weight; } normalizeWeights(normalize); } }
ParticleFilter { public void updateSensor(double x, double y) { float normalize = 0.f; for (int i = 0; i < numParticles; i++) { final double sqrX = (x - particleList.get(i).getX()) * (x - particleList.get(i).getX()); final double sqrY = (y - particleList.get(i).getY()) * (y - particleList.get(i).getY()); double sqrt = Math.sqrt(sqrX + sqrY); if (sqrt == 0.f) { sqrt = 0.000001f; } final double dist = 1.f/sqrt; final double weight = dist; particleList.get(i).setWeight(weight); normalize += weight; } normalizeWeights(normalize); } ParticleFilter(final Context ctx, UserPositionManager userPositionManager); }
ParticleFilter { public void updateSensor(double x, double y) { float normalize = 0.f; for (int i = 0; i < numParticles; i++) { final double sqrX = (x - particleList.get(i).getX()) * (x - particleList.get(i).getX()); final double sqrY = (y - particleList.get(i).getY()) * (y - particleList.get(i).getY()); double sqrt = Math.sqrt(sqrX + sqrY); if (sqrt == 0.f) { sqrt = 0.000001f; } final double dist = 1.f/sqrt; final double weight = dist; particleList.get(i).setWeight(weight); normalize += weight; } normalizeWeights(normalize); } ParticleFilter(final Context ctx, UserPositionManager userPositionManager); void initialize(double curX, double curY); void updateAction(double x, double y); void updateSensor(double x, double y); void resampling(); void clearParticles(); void setShowParticles(boolean enabled); void setNumParticles(int particles); void setScale(float scale); NicGeoPoint calculatePosition(); }
ParticleFilter { public void updateSensor(double x, double y) { float normalize = 0.f; for (int i = 0; i < numParticles; i++) { final double sqrX = (x - particleList.get(i).getX()) * (x - particleList.get(i).getX()); final double sqrY = (y - particleList.get(i).getY()) * (y - particleList.get(i).getY()); double sqrt = Math.sqrt(sqrX + sqrY); if (sqrt == 0.f) { sqrt = 0.000001f; } final double dist = 1.f/sqrt; final double weight = dist; particleList.get(i).setWeight(weight); normalize += weight; } normalizeWeights(normalize); } ParticleFilter(final Context ctx, UserPositionManager userPositionManager); void initialize(double curX, double curY); void updateAction(double x, double y); void updateSensor(double x, double y); void resampling(); void clearParticles(); void setShowParticles(boolean enabled); void setNumParticles(int particles); void setScale(float scale); NicGeoPoint calculatePosition();  }