예제 #1
0
 def evaluate (self):
     old = self.distance
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Update observers.
     if self.distance != old:
         self.notify ()
예제 #2
0
 def __init__ (self, link, scheduler, table, pos, angle, into = None,
         level = 0, exclude = exclude):
     Observable.__init__ (self)
     DistanceSensor.__init__ (self, table, pos, angle, self.RANGE, into,
             level, exclude)
     self.link = link
     self.scheduler = scheduler
     self.value = None
     self.register (self.__update)
     self.evaluate ()
예제 #3
0
 def evaluate (self):
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Convert to sharps voltage.
     d = self.distance
     if self.distance is None:
         d = self.RANGE
     if d < self.NEAR:
         self.value = d / self.NEAR * (self.A + self.B / self.NEAR)
     else:
         self.value = self.A + self.B / d
     # Update observers.
     self.notify ()
     # Prepare next update.
     self.scheduler.schedule (self.scheduler.date
             + int (self.scheduler.tick * 0.040), self.evaluate)
예제 #4
0
 def evaluate (self):
     # Compute real distance.
     DistanceSensor.evaluate (self)
     # Convert to sensor voltage.
     d = self.distance
     if self.distance is None:
         d = self.RANGE
     if d < 22.5:
         self.value = -0.014 * d * d + 0.41 * d + 7
     else:
         self.value = -0.657 + 220.431 / d
     self.value *= 0.1 * self.factor
     # Update observers.
     self.notify ()
     # Prepare next update.
     self.scheduler.schedule (self.scheduler.date
             + int (self.scheduler.tick * 0.03), self.evaluate)
예제 #5
0
 def __init__ (self, *args):
     Observable.__init__ (self)
     DistanceSensor.__init__ (self, *args)