在Vrep中设置路径和pioneer小车,网络上已有较多通信配置的优秀教程 这里不再班门弄斧。相机位置安装在小车上方。
主要思路是通过canny检测路径曲线,通过某一列曲线和画面中心的距离,确定偏离的误差,通过PID控制器进行跟踪
vrep.simxFinish(-1) # 闭所有与VREP之前的连接
clientID = vrep.simxStart('127.0.0.1',19997,True,True,5000,5) # 参数解释可查看API文档
if clientID!=-1: #检查连接是否成功
print ('Connected to remote API server')
#template_init begin
template = cv2.imread("model.jpg")
#template_init end
#bot connection begin
robot = Robot()
fz = FZ()
while True:
# rgb
res,resolution,image = vrep.simxGetVisionSensorImage(clientID,robot.visionSensor,0,vrep.simx_opmode_streaming)
time.sleep(0.