代码拉取完成,页面将自动刷新
function robotTest()
disp('Program started');
vrep=remApi('remoteApi'); % using the prototype file (remoteApiProto.m)
vrep.simxFinish(-1); % just in case, close all opened connections
clientID=vrep.simxStart('127.0.0.1',19999,true,true,5000,5);
if clientID == -1
disp('Failed connecting to remote API server');
end
[retVal,leftMotor] = vrep.simxGetObjectHandle(clientID,'remoteApiControlledBubbleRobLeftMotor',vrep.simx_opmode_oneshot_wait);
check(vrep,retVal, 'failed to get left motor', 'got left motor');
[retVal,rightMotor] = vrep.simxGetObjectHandle(clientID,'remoteApiControlledBubbleRobRightMotor',vrep.simx_opmode_oneshot_wait);
check(vrep,retVal, 'failed to get right motor', 'got right motor');
[retVal,noseSensor] = vrep.simxGetObjectHandle(clientID,'remoteApiControlledBubbleRobSensingNose',vrep.simx_opmode_oneshot_wait);
check(vrep,retVal, 'failed to get nose sensor', 'got nose sensor');
[retVal, vel] = vrep.simxGetObjectFloatParameter(clientID, leftMotor, 2012, vrep.simx_opmode_oneshot_wait);
vel
[retVal]=vrep.simxSetJointTargetVelocity(clientID,leftMotor,3*pi,vrep.simx_opmode_oneshot_wait);
check(vrep,retVal, 'velocity left failed', 'velocity left set');
[retVal]=vrep.simxSetJointTargetVelocity(clientID,rightMotor,pi,vrep.simx_opmode_oneshot_wait);
check(vrep,retVal, 'velocity right failed', 'velocity right set');
vrep.simxAddStatusbarMessage(clientID, 'this is a test', vrep.simx_opmode_oneshot_wait);
[retVal, vel] = vrep.simxGetObjectFloatParameter(clientID, leftMotor, 2012, vrep.simx_opmode_oneshot_wait);
vrep.simxAddStatusbarMessage(clientID, 'this is a test', vrep.simx_opmode_oneshot_wait);
try
while (vrep.simxGetConnectionId(clientID)>-1)
[retVal, nose] = vrep.simxGetObjectFloatParameter(clientID, noseS, 2012, vrep.simx_opmode_oneshot_wait);
nose
end
disp('exiting');
vrep.delete(); % call the destructor!
catch err
vrep.simxFinish(clientID); % close the line if still open
vrep.delete(); % call the destructor!
end;
disp('Program ended');
end
function check(vrep, retVal, textError, textNoError)
if (retVal==vrep.simx_error_noerror)
disp(textNoError);
else
disp(textError);
end
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。