Ejemplo n.º 1
0
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.
right1 = [0, 0, 0, 0, 1]  # Sensor reads strongly to the right.
Ejemplo n.º 2
0
 def get_black_calibration(self):
     return line_sensor.get_black_line()
Ejemplo n.º 3
0
poll_time = 0.01  # Time between polling the sensor, seconds.

slight_turn_speed = int(.8 * speed)
turn_speed = int(.8 * 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.

gpg_en = 0  #Enable/disable gopigo
msg_en = 0  #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.
Ejemplo n.º 4
0
	def black_line_set_OnButtonClick(self,event):
		for i in range(2):
			line_sensor.get_sensorval()
		line_sensor.set_black_line()
		line_val=line_sensor.get_black_line()
		self.label.SetLabel("Black Line : "+str(line_val))
Ejemplo n.º 5
0
 def black_line_set_OnButtonClick(self, event):
     for i in range(2):
         line_sensor.get_sensorval()
     line_sensor.set_black_line()
     line_val = line_sensor.get_black_line()
     self.label.SetLabel("Black Line : " + str(line_val))
Ejemplo n.º 6
0
 def get_black_calibration(self):
     return line_sensor.get_black_line()
Ejemplo n.º 7
0
print "WHITE LINE SETUP!!"
while True:
    print "Keep all the sensors over a white strip and press [Enter]"
    raw_input()
    print "--> Line sensor value: ",
    get_sensorval()
    print get_sensorval()
    print "If the reading look good, press 'y' and [Enter] to continue"
    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 "Keep all the sensors over a black strip and press [Enter]",
    raw_input()
    print "--> Line sensor value: ",
    get_sensorval()
    print get_sensorval()
    print "If the reading look good, press 'y' and [Enter] to continue"
    inp = raw_input()
    if inp == 'y':
        line_sensor.set_black_line()
        break
print "White Line Values set: ",
print line_sensor.get_black_line()
Ejemplo n.º 8
0
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()