2014-05-12 05:44:25 +02:00
|
|
|
# -*- 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):
|
|
|
|
|
2014-11-20 08:50:11 +01:00
|
|
|
def __init__(self, x0=0, velocity=1, noise_var=0.0):
|
2014-05-12 05:44:25 +02:00
|
|
|
""" x0 - initial position
|
|
|
|
velocity - (+=right, -=left)
|
2014-11-20 08:50:11 +01:00
|
|
|
noise_var - noise variance, 0== no noise
|
2014-05-12 05:44:25 +02:00
|
|
|
"""
|
|
|
|
self.x = x0
|
|
|
|
self.velocity = velocity
|
2014-11-20 08:50:11 +01:00
|
|
|
self.noise = math.sqrt(noise_var)
|
2014-05-12 05:44:25 +02:00
|
|
|
|
|
|
|
def sense(self):
|
|
|
|
self.x = self.x + self.velocity
|
|
|
|
return self.x + random.randn() * self.noise
|