import random

from particle_filter.robot import robot

if __name__ == '__main__':
    myrobot = robot()
    myrobot = myrobot.move(0.1, 5.0)
    Z = myrobot.sense()

    N = 1000
    p = []
    for i in range(N):
        x = robot()
        x.set_noise(0.05, 0.05, 5.0)
        p.append(x)

    p2 = [particle.move(.1, 5.) for particle in p]
    p = p2

    w = [particle.measurement_prob(Z) for particle in p]

    p3 = []

    max_weight = max(w) * 2
    index = random.randrange(N)
    beta = 0

    for _ in range(N):
        beta += random.random() * max_weight

        while w[index] < beta:
import random

from particle_filter.robot import robot, eval

if __name__ == '__main__':

    myrobot = robot()
    N = 1000
    T = 10  # Leave this as 10 for grading purposes.

    p = []
    for i in range(N):
        r = robot()
        r.set_noise(0.05, 0.05, 5.0)
        p.append(r)

    turn = .1
    move = 5.

    for t in range(T):
        myrobot = myrobot.move(turn, move)
        Z = myrobot.sense()

        p = [particle.move(turn, move) for particle in p]
        w = [particle.measurement_prob(Z) for particle in p]

        p3 = []
        index = int(random.random() * N)
        beta = 0.0
        mw = max(w)
        for i in range(N):
예제 #3
0
from particle_filter.robot import robot

if __name__ == '__main__':
    N = 1000

    particles = [robot() for _ in range(N)]

    print(len(particles))
from math import pi

from particle_filter.robot import robot

if __name__ == '__main__':
    myrobot = robot()
    myrobot.set_noise(5, .1, 5)

    myrobot.set(30, 50, pi / 2)
    myrobot = myrobot.move(-pi / 2, 15)
    print(myrobot.sense())
    myrobot = myrobot.move(-pi / 2, 10)
    print(myrobot.sense())