66f20b745e
Added more examples and cleaned up explanations on modifying R and Q. In particular, the filter setting for R was not the same as the simulated noise for no obvious reason. Also, names were bad R instead of R_var, for example.
27 lines
610 B
Python
27 lines
610 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Sun May 11 13:21:39 2014
|
|
|
|
@author: rlabbe
|
|
"""
|
|
|
|
from __future__ import print_function, division
|
|
|
|
import numpy.random as random
|
|
import math
|
|
|
|
class DogSensor(object):
|
|
|
|
def __init__(self, x0=0, velocity=1, noise_var=0.0):
|
|
""" x0 - initial position
|
|
velocity - (+=right, -=left)
|
|
noise_var - noise variance, 0== no noise
|
|
"""
|
|
self.x = x0
|
|
self.velocity = velocity
|
|
self.noise = math.sqrt(noise_var)
|
|
|
|
def sense(self):
|
|
self.x = self.x + self.velocity
|
|
return self.x + random.randn() * self.noise
|