def run(self): # You should insert a getDevice-like function in order to get the # instance of a device of the robot. Something like: #print self.get_proximities() pimg = self.snapshot(False) print pimg #print "proximities: " #print self.get_proximities() training_data = read_training_data() self.ann.do_training(training_data) self.ann.stop_training() # Main loop while True: # Read the sensors: sens = self.get_proximities() # Process sensor data here. self.enter_input(sens) self.ann.execute() output = self.get_output() if self.ann.is_hardwired(): self.set_wheel_speeds(output[0]-output[2]+uniform(0.3,0.5), output[1]-output[2]+uniform(0.3,0.5)) else: self.set_wheel_speeds(output[0], output[1]) # Enter here functions to send actuator commands, like: # led.set(1) # Perform a simulation step of 64 milliseconds # and leave the loop when the simulation is over if self.step(64) == -1: break
def run(self): # You should insert a getDevice-like function in order to get the # instance of a device of the robot. Something like: # led = self.getLed('ledname') ''' 1. get_proximities(): vector with values from the 8 distance sensors 2. snapshot() 3. move, move_wheels, set_wheel_speeds 4. run_timestep, do_timed_action ''' #self.move_wheels(left, right, duration) #print self.get_proximities() #pimg = self.snapshot(True) #print "proximities: " #print self.get_proximities() training_data = read_training_data() self.ann.do_training(training_data) # Main loop while True: # Read the sensors: # Enter here functions to read sensor data, like: #for s in self.sensors: #val = s.getValue() sens = self.get_proximities() self.enter_input(sens) self.ann.execute() output = self.get_output() left = 0 right = 0 for i in range(len(output) / 2): left += output[i] right += output[len(output) - 1 - i] self.set_wheel_speeds(left, right) # Process sensor data here. #self.enter_input(img) # Enter here functions to send actuator commands, like: # led.set(1) # Perform a simulation step of 64 milliseconds # and leave the loop when the simulation is over if self.step(64) == -1: break
def run(self): # You should insert a getDevice-like function in order to get the # instance of a device of the robot. Something like: # led = self.getLed('ledname') ''' 1. get_proximities(): vector with values from the 8 distance sensors 2. snapshot() 3. move, move_wheels, set_wheel_speeds 4. run_timestep, do_timed_action ''' #self.move_wheels(left, right, duration) #print self.get_proximities() #pimg = self.snapshot(True) #print "proximities: " #print self.get_proximities() training_data = read_training_data() self.ann.do_training(training_data) # Main loop while True: # Read the sensors: # Enter here functions to read sensor data, like: #for s in self.sensors: #val = s.getValue() sens = self.get_proximities() self.enter_input(sens) self.ann.execute() output = self.get_output() left = 0 right = 0 for i in range(len(output)/2): left += output[i] right += output[len(output)-1-i] self.set_wheel_speeds(left, right) # Process sensor data here. #self.enter_input(img) # Enter here functions to send actuator commands, like: # led.set(1) # Perform a simulation step of 64 milliseconds # and leave the loop when the simulation is over if self.step(64) == -1: break