I
iw5t
@iw5t
0
声望
4
楼层
1363
资料浏览
0
粉丝
0
关注
iw5t 发布的帖子
-
追小球的小车中x_output正负号的思考
追小球的小车中代码 car.run(-h_output-x_output,-h_output+x_output)感觉写反了,前面应该是+x_output,后面是-x_output.因为当ERROR=blob[5]-0.5*wide为正时,代表小球在视野右半部分,此时小车应该右转,使小球在视野中央,右转的话左轮速度>右轮速度,所以car(l,r)中前面应该是+x_output,后面是-x_output,才能使l>r,右转
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) ''' for b in blobs: # Draw a rect around the blob. img.draw_rectangle(b[0:4]) # rect img.draw_cross(b[5], b[6]) # cx, cy ''' 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)