Esempio n. 1
0
poll_time = 0.01  # Time between polling the sensor, seconds.

slight_turn_speed = int(.7 * fwd_speed)
turn_speed = int(.7 * fwd_speed)

last_val = [0] * 5  # An array to keep track of the previous values.
curr = [0] * 5  # An array to keep track of the current values.

gopigo.set_speed(fwd_speed)

gpg_en = 1  # Enable/disable gopigo
msg_en = 1  # Enable messages on screen.  Turn this off if you don't want messages.

# Get line parameters
line_pos = [0] * 5
white_line = line_sensor.get_white_line()
black_line = line_sensor.get_black_line()
range_sensor = line_sensor.get_range()
threshold = [a + b / 2 for a, b in
			 zip(white_line, range_sensor)]  # Make an iterator that aggregates elements from each of the iterables.

# Position to take action on
mid = [0, 0, 1, 0, 0]  # Middle Position.
mid1 = [0, 1, 1, 1, 0]  # Middle Position.
small_l = [0, 1, 1, 0, 0]  # Slightly to the left.
small_l1 = [0, 1, 0, 0, 0]  # Slightly to the left.
small_r = [0, 0, 1, 1, 0]  # Slightly to the right.
small_r1 = [0, 0, 0, 1, 0]  # Slightly to the right.
left = [1, 1, 0, 0, 0]  # Slightly to the left.
left1 = [1, 0, 0, 0, 0]  # Slightly to the left.
right = [0, 0, 0, 1, 1]  # Sensor reads strongly to the right.
Esempio n. 2
0
	def white_line_set_button_OnButtonClick(self,event):
		for i in range(2):
			line_sensor.get_sensorval()
		line_sensor.set_white_line()
		line_val=line_sensor.get_white_line()
		self.label.SetLabel("White Line : "+str(line_val))
Esempio n. 3
0
 def get_white_calibration(self):
     return line_sensor.get_white_line()
Esempio n. 4
0
		#	val=line_sensor.read_sensor()
	
print "WHITE LINE SETUP"
while True:	
	print "\nKeep all the sensors over a white strip and press ENTER",
	raw_input()
	print "--> Line sensor readings: ",
	get_sensorval()
	print get_sensorval()
	print "If the reading look good, press 'y' and Enter to continue, any other key to read again" 
	inp=raw_input()
	if inp=='y':
		line_sensor.set_white_line()
		break
print "White Line values set:",
print line_sensor.get_white_line()

print "BLACK LINE SETUP"
while True:	
	print "\nKeep all the sensors over a black strip and press ENTER",
	raw_input()
	print "--> Line sensor readings: ",
	get_sensorval()
	print get_sensorval()
	print "If the reading look good, press 'y' and Enter to continue, any other key to read again" 
	inp=raw_input()
	if inp=='y':
		line_sensor.set_black_line()
		break
print "Black Line values set:",
print line_sensor.get_black_line()