This commit is contained in:
NikolajDanger
2022-10-26 10:47:04 +02:00
parent a7ffe3f581
commit ad57381bc0

View File

@ -40,28 +40,45 @@ def time_to_landmark(est_pose, landmark):
"""Kør indenfor 1 meter""" """Kør indenfor 1 meter"""
pass pass
def drive_until_stopped(est_pose): def drive_until_stopped(noah):
noah.go_diff(POWER, POWER+RIGHT_WHEEL_OFFSET, 1, 1)
start = time.time()
while True:
forward_dist = noah.read_front_sensor()
if forward_dist < 1000:
noah.stop()
break
end = time.time()
return end - start
def drunk_drive(noah):
pass pass
def inch_closer(): def inch_closer(noah):
pass noah.go_diff(POWER, POWER+RIGHT_WHEEL_OFFSET, 1, 1)
while True:
forward_dist = noah.read_front_sensor()
if forward_dist < 300:
noah.stop()
break
def main(): def main():
landmark_order = LANDMARKS + [ landmark_order = LANDMARKS + [
LANDMARKS[0] LANDMARKS[0]
] ]
noah = robot.Robot() noah = robot.Robot() # Noah er vores robots navn
for landmark in landmark_order: for landmark in landmark_order:
while True: while True:
est_pose = look_around() est_pose = look_around()
est_pose = turn_towards_landmark(est_pose, landmark) est_pose = turn_towards_landmark(est_pose, landmark)
drive_time = time_to_landmark(est_pose, landmark) drive_time = time_to_landmark(est_pose, landmark)
if not drive_until_stopped(drive_time) == drive_time: if not abs(drive_until_stopped(noah) - drive_time) < 0.5:
# drive around drunk_drive(noah)
continue continue
inch_closer() inch_closer(noah)
break break