#from camera import camera from ultrasonic import ultrasonic from infrared import infrared from line_tracker import line_tracker #import cv2 import time address='192.168.0.101' #cam = camera(address) #cam.start() inf = infrared(address) inf.start() ult = ultrasonic(address) ult.start() lt = line_tracker(address) lt.start() inf_t = time.time() while True: try: t = time.time() # if cam.image!=[]: # cv2.imshow("image",cam.image) # cv2.waitKey(1) if t-inf_t>1: print("infrared left,right: ",inf.left,inf.right) print("ultrasonic: ",ult.measurement) print("line_tracker: ",lt.data) inf_t = t
from ultrasonic import ultrasonic from infrared import infrared from line_tracker import line_tracker import time # Chinese comments are just for my own to understand the code address = "192.168.0.106" #定义了IP,就是机器人的IP地址 inf = infrared(address) inf.start() ult = ultrasonic(address) ult.start() lt = line_tracker(address) #这个line_tracker是啥,还需要看。py引包还不太熟 from motor import motor mot = motor(address) lt.start() #开启了灰度传感器 inf_t = time.time() thr = 350 #这是灰度传感器的值,数值越小表示越黑 while True: try: t = time.time() if t - inf_t > 1: #在开始执行之后 print("line_tracker: ", lt.data) if lt.data[2] < thr: mot.command("forward", 10, 0.3) #马达前进,机器人前进;数值为前进速度和时间 print("Forward") else: