matlab-vrep程序控制方法


matlab控制程序 .m文件控制vrep常常包括以下步驟:

1.引入模塊

%  load api library
vrep=remApi('remoteApi');

 

2.建立連接,先關閉上一次連接

% close all the potential link
vrep.simxFinish(-1);

clientID=vrep.simxStart('127.0.0.1',19997,true,true,5000,5);

 

%設置仿真時間步長

tstep = 0.005; % 5ms per simulation pass
vrep.simxSetFloatingParameter(clientID,vrep.sim_floatparam_simulation_time_step,tstep,vrep.simx_opmode_oneshot);

根據需要,設置m文件和vrep環境時間一致:

% open the synchronous mode to control the objects in vrep
vrep.simxSynchronous(clientID,true);

 

3.開始仿真

%% Simulation Initialization
vrep.simxStartSimulation(clientID,vrep.simx_opmode_oneshot);

 

相應的,在主程序部分,往往是循環里頭:

# make step forward

vrep.simxSynchronousTrigger(clientID);

 

4.主程序部分

 

5.結束仿真

 

 

6.斷開連接

##### Close the connection to V-REP

vrep.simxFinish(-1); % close the link
vrep.delete(); % destroy the 'vrep' class

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM