@kidswong999 openmv4 h7
3
3ksq
@3ksq
0
声望
4
楼层
306
资料浏览
0
粉丝
0
关注
3ksq 发布的帖子
-
电机和舵机是否能同时驱动?
THRESHOLD = (40, 100, -128, 127, -128, 127) # Grayscale threshold for dark things... import sensor, image, time from pyb import LED, Servo from tb6612 import Motor servo3 = Servo(3) servo3.angle(0) m1 = Motor(1) # motor 1: A0 and A1 #m2 = Motor(2) # motor 2: B0 and B1 LED(1).on() LED(2).on() LED(3).on() sensor.reset() sensor.set_vflip(True) sensor.set_hmirror(True) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000. #sensor.set_windowing([0,20,80,40]) sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds clock = time.clock() # to process a frame sometimes. while(True): clock.tick() m1.set_speed(10) # Forward #m2.set_speed(10) # Forward img = sensor.snapshot().binary([THRESHOLD]) line = img.get_regression([(100,100)], robust = True) if (line): rho_err = abs(line.rho())-img.width()/2 if line.theta()>90: theta_err = line.theta()-180 else: theta_err = line.theta() img.draw_line(line.line(), color = 127) print(rho_err,line.magnitude(),theta_err) if line.magnitude()>8: servo3.angle(0+theta_err)