v-rep与vs2013通信
step1,打开vs新建一个项目。
step2,鼠标右键点击项目名,选择“属性”---》》》“通用配置” ---》》》“VC++目录”---》》》“包含目录” 点击编辑,点击“...”,添加目录“C:\Program Files\V-REP3\V-REP_PRO_EDU\programming\common”(vrep安装的文件夹下)
还有include目录和remoteAPI目录。 点击确定。
添加库目录为: C:\Program Files\V-REP3\V-REP_PRO_EDU\programming
step,点击 “c/c++”,选择“预处理器”,选择“预处理器定义”,编辑
修改为:
WIN32
NDEBUG
_CONSOLE
NON_MATLAB_PARSING
MAX_EXT_API_CONNECTIONS=255zasda
点击确定,应用,确定。
step3,编写测试代码如下
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
extern "C" {
#include "extApi.h"
}int main()
{
int clientID = simxStart("127.0.0.1", 2000, true, true, 2000, 5);
if (clientID != -1)
{
printf("success");
}
else
{
printf("error");
}
return 0;
}
当我们点击运行时,会出现如下错误:
step4,此时,需要链接库。
下载remoteAPI.lib。放到C:\Program Files\V-REP3\V-REP_PRO_EDU\programming下 ,以便后面使用。
然后将remoteAPI.lib放入项目文件夹下。点击“项目”---》》》“属性”———》》》“配置属性”———》》“链接器”———》》》在“附加依赖项”中添加remoteAPI.lib。
vrep在子线程中添加如下代码: simExtRemoteApiStart(2000)。
就可以了。
在进行通信时,首先运行vrep仿真,再运行vs。