CoppeliaSim/Vrep Remote API 封装
2020-03-06 16:20
2196 查看
自己把CoppeliaSim remote API 中的部分函数封装了类,可以完成机器人的关节空间控制,以及笛卡尔空间控制。
VS2017 和 CoppeliaSim/Vrep 的配置参见我的博客:
CoppeliaSim Remote API 实操
关节空间控制,需在CoppeliaSim/Vrep中关闭逆运动学,笛卡尔空间控制开启逆运动学。
下面是头文件,全部文件请在下方链接下载:(包括VS的永久配置文件,需按照自己文件的路径稍作修改)
https://download.csdn.net/download/qq_29696095/12192775
// Copyright SJTU // author Li Wang 05liwang@sjtu.edu.cn 935342669@qq.com // this file is used to wrap the legacy remote API of CoppeliaSim // all the unit of data from coppeliasim is m or s or N or deg // orientation is euler anles, alpha, beta and gamma // T = rotx(a)*roty(b)*rotz(g) #ifndef COPPELIA_H_ #define COPPELIA_H_ extern "C" { #include "extApi.h" #include "extApiPlatform.h" } #define M_PI 3.14159265358979323846 // pi typedef unsigned char uchar; // opmode explaination // http://www.360doc.com/content/19/0720/09/32181961_849906173.shtml const int NON_BLOCK_MODE = simx_opmode_oneshot; const int BLOCK_MODE = simx_opmode_blocking; const int STREAMING_MODE = simx_opmode_streaming; // The function executed fine const int SIM_RETRUN_OK = simx_return_ok; // There is no command reply in the input buffer. This should not always be // considered as an error, depending on the selected operation mode const int SIM_RETRUN_NOVALUE_FLAG = simx_return_novalue_flag; // The function timed out (probably the network is down or too slow) const int SIM_RETRUN_TIMEOUT_FLAG = simx_return_timeout_flag; // The specified operation mode is not supported for the given function const int SIM_RETRUN_ILLEGAL_OPMODE_FLAG = simx_return_illegal_opmode_flag; // The function caused an error on the server side (e.g. an invalid handle was // specified) const int SIM_RETRUN_REMOTE_ERROR_FALG = simx_return_remote_error_flag; // The communication thread is still processing previous split command of the // same type const int SIM_RETRUN_SPLIT_PROCESS_FLAG = simx_return_split_progress_flag; // The function caused an error on the client side const int SIM_RETRUN_LOCAL_FLAG = simx_return_local_error_flag; // simxStart was not yet called const int SIM_RETRUN_INITIALIZE_ERROR_FLAG = simx_return_initialize_error_flag; class Coppelia { public: Coppelia(); ~Coppelia(); int ConnectCoppeliaSim(int port_number, bool wait_until_connected, bool do_not_reconnect_once_disconnected, int time_out_in_ms, int commthread_cycle_in_ms); void DisconnectCoppeliasSim(); int StartSimulation(int operation_mode); int StopSimulation(int operation_mode); int GetObjectHandle(const char *object_name, int operation_mode, int *handle); int GetJointPosition(int joint_handle, int operation_mode, float *position); int GetObjectPosition(int object_handle, int relative_to_object_handle, int operation_mode, float *position); int GetObjectOrientation(int object_handle, int relative_to_object_handle, int operation_mode, float *orientation); int GetObjectPositionAndOrientation(int object_handle, int relative_to_object_handle, int operation_mode, float *Pos_Orient); int SetJointPosition(int joint_handle, int operation_mode, float position); int SetRobotJointPosition(int *joint_handle, int joint_number, int operation_mode, float *position); int SetJointTargetPosition(int joint_handle, int operation_mode, float position); int SetJointTargetVelocity(int joint_handle, int operation_mode, float position); int SetObjectPosition(int object_handle, int relative_to_object_handle, int operation_mode, float *position); int SetObjectOrientation(int object_handle, int relative_to_object_handle, int operation_mode, float *orientation); int SetObjectPositionAndOrientation(int object_handle, int relative_to_object_handle, int operation_mode, float *Pos_Orient); int PauseCommunication(bool pause); private: int client_ID_ = -1; int port_number_ = 0; }; #endif // !COPPELIASIMCLIENT_H_
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- android UiAutomator基本api的二次封装
- C语言封装sqlite3_API
- 淘宝api自己的封装之python版
- Wrapping calls to the Rational Functional Tester API——调用Rational Functional Tester封装的API...
- C# 视频监控系列(11):H264播放器——封装API[HikPlayM4.dll] (5)
- 如何封装HAL API以及对应的JAVA API
- 将百度音乐API的返回结果封装到json中
- Struts2框架笔记02_API_结果页面配置_数据的封装
- Java封装自己的Api
- 视频监控 封装[PlayCtrl.dll]的API (1)
- SpringCloud 微服务简介及搭建(本文使用Spring封装后的API,实现负载均衡的功能)
- 封装ibm流程和人工任务api
- appium笔记六:appium常用api二次封装
- Python量化交易平台开发教程系列2-类CTP交易API的Python封装设计
- Three.js的轻量级封装框架Sim.js解析(1)
- 微信小程序开发实践点滴——Bmob基本REST API的python封装
- Lucene.Net的服务器封装+APi组件 (开源)
- $微信小程序开发实践点滴——Bmob基本REST API的python封装
- Mysql API之C++封装(一)
- tp Api 接口类封装