具体实现代码如下:
if min(min(img(:,:))) > 20
% 进行旋转
vrep.simxSetJointTargetVelocity(clientID, motorLeft, direct, vrep.simx_opmode_oneshot);
vrep.simxSetJointTargetVelocity(clientID, motorRight, -direct, vrep.simx_opmode_oneshot);
% 旋转到画面的中间出现出现路为止
while img(480,320) > 20
code = 1;
while code
[code, size, img] = vrep.simxGetVisionSensorImage2(clientID, camera, 1, vrep.simx_opmode_oneshot);
end
end
% 更新误差
err = 0;
new_err = 0;
|