32 lines
611 B
Markdown
32 lines
611 B
Markdown
import robot
|
|
import time
|
|
|
|
robot.move(0.00006)
|
|
while True:
|
|
if robot.get_sensors()[0]["hitpoint"]["x"] is not None:
|
|
robot.turn(0.001)
|
|
elif robot.get_sensors()[1]["hitpoint"]["x"] is not None:
|
|
robot.turn(-0.001)
|
|
else:
|
|
robot.turn(0)
|
|
time.sleep(0.1)
|
|
|
|
|
|
|
|
|
|
|
|
import robot
|
|
import time
|
|
|
|
robot.move(0.00006)
|
|
while True:
|
|
left = robot.get_sensors()[0]["distance"]
|
|
right = robot.get_sensors()[1]["distance"]
|
|
print(str(int(left)) + "\t" + str(int(right)))
|
|
if left < 55:
|
|
robot.turn(0.01)
|
|
elif right < 55:
|
|
robot.turn(-0.01)
|
|
else:
|
|
robot.turn(0)
|
|
time.sleep(0.1) |