<|file_name|>BraitenbergVehicle2b.py<|end_file_name|><｜fim▁begin｜>"""
Braitenberg Vehicle2b
The more light sensed on the left side the faster the right motor moves.
The more light sensed on the right side the faster the left motor moves.
This causes the robot to turn towards a light source.
"""

from pyrobot.brain import Brain, avg

class Vehicle(Brain):
   def <|fim_middle|>(self):
      self.robot.light[0].units = "SCALED"
   def step(self):
      leftSpeed  = max([s.value for s in self.robot.light[0]["right"]])
      rightSpeed = max([s.value for s in self.robot.light[0]["left"]])
      print "leftSpeed, rightSpeed:", leftSpeed, rightSpeed
      self.motors(leftSpeed,  rightSpeed) 

def INIT(engine):
   if engine.robot.type not in ['K-Team', 'Pyrobot']:
      raise "Robot should have light sensors!"
   return Vehicle('Braitenberg2a', engine)
      
<｜fim▁end｜>
setup