Python可以用Pycharm与Spyder,推荐Spyder,可以用Ipython。随时可以观察到变量窗口,方便调试

新建Python文件夹,将vrep根目录V-REP_PRO_EDU_V3_5_0_Mac/programming/remoteApiBindings/python/文件拷贝进去

准备以下文件:

verp\programming\remoteApiBindings\python\python目录下的:

根据系统选择:“remoteApi.dll” (Windows), “remoteApi.dylib” (Mac) or “remoteApi.so” (Linux)

打开V-REP,new scene,拖入一个UR5机械臂(也可以用别的模型)

添加代码到lua中,保存修改

simExtRemoteApiStart(19999)

注意UR5模型有自带的Lua脚本,不影响通信例子


先运行V-REP仿真,再运行你的Python程序。

若程序正常运行,可看到V-REP的状态栏中有如下显示:“Hello V-REP”,Python控制台出现鼠标的位置,说明Python与V-REP正常通信。

V-REP 与 Python 通信的关键脚本代码如下:

% V-REP脚本:
simExtRemoteApiStart(19999)
% Python端:
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);
Reference:
User Manual: