logo

追小球得小车不会转

2019-03-21 14:45
Y
u14w

if blobs:

max_blob = find_max(blobs)

x_error = max_blob[5]-img.width()/2

h_error = max_blob[2]*max_blob[3]-size_threshold

print("x error: ", x_error)

img.draw_rectangle(max_blob[0:4]) # rect

img.draw_cross(max_blob[5], max_blob[6]) # cx, cy

x_output=x_pid.get_pid(x_error,1)

h_output=h_pid.get_pid(h_error,1)

print("h_output",h_output)

car.run(-h_output-x_output,-h_output+x_output)

else:

car.run(18,-18)

当程序else时不会转;

如果car.run(18,18)就会动;

只要是负值就不会动

2019-03-21 15:38
I
网红小智智 星瞳科技

测试:

car.run(100,100)

car.run(100,-100)

car.run(-100,100)

car.run(-100,-100)