Exemplo 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.
stop = [1, 1, 1, 1, 1]  # Sensor reads stop.
Exemplo n.º 2
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.
right1 = [0, 0, 0, 0, 1]  # Sensor reads strongly to the right.