当前位置:网站首页>[coppeliasim4.3] C calls UR5 in the remoteapi control scenario
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario
2022-07-03 07:28:00 【Ten year dream laboratory】
Screenshot
Video demo
note :
One 、 Add code to the scenario script , Turn on the server :
function sysCall_init()
-- Start remote API server
local port=3000
simRemoteApi.start(port)
corout=coroutine.create(coroutineMain)
end
Two 、C# The client connects to the server , And get the joint handle
_id = Api.Connect(textBoxAddress.Text, (int)numericUpDownPort.Value);
if (Api.IsConnected(_id))
{
for (int i = 0; i < _jointHandle.Length; i++)
{
_jointHandle[i] = Api.GetObjectHandle(_id, _jointPrefix + (i + 1));
}
}
3、 ... and 、 Copy from the installation directory include and remoteApi To C# project , Generate dll、lib
Directory source location
Directory target location
Copy the generated library to C# Project compilation output directory
Four 、C# call C++ library
using System;
using System.Runtime.InteropServices;
namespace CoppeliaSimCSharpAPI.TestForm
{
internal class Api
{
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int Connect(string address, int port);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int Disconnect(int id);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern bool IsConnected(int id);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int GetJointPosition(int id, int[] jointHandle, float[] position, int jointCount);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int GetObjectHandle(int id, string objectName);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int MoveJoint(int id, int[] jointHandle, float[] position, bool inTorqueForceMode, int jointCount);
[DllImport("CoppeliaSimCSharpAPI.dll")]
public static extern int SendInfo(int id, string message, bool blocking);
}
}
5、 ... and 、 Move the manipulator and get the position
private void buttonMove_Click(object sender, EventArgs e)
{
var position = new float[]
{
(float)numericUpDownJ1.Value,
(float)numericUpDownJ2.Value,
(float)numericUpDownJ3.Value,
(float)numericUpDownJ4.Value,
(float)numericUpDownJ5.Value,
(float)numericUpDownJ6.Value
};
Api.MoveJoint(_id, _jointHandle, position, true, _jointHandle.Length);
}
private void buttonGetPosition_Click(object sender, EventArgs e)
{
var position = new float[6];
Api.GetJointPosition(_id, _jointHandle, position, _jointHandle.Length);
MessageBox.Show($"{position[0]}\r\n" +
$"{position[1]}\r\n" +
$"{position[2]}\r\n" +
$"{position[3]}\r\n" +
$"{position[4]}\r\n" +
$"{position[5]}",
"Now position");
}
The End
边栏推荐
- Use of framework
- C WinForm framework
- Comparison of advantages and disadvantages between most complete SQL and NoSQL
- Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
- TypeScript let与var的区别
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- 【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
- C代码生产YUV420 planar格式文件
- SharePoint modification usage analysis report is more than 30 days
- Unified handling and interception of exception exceptions of vertx
猜你喜欢
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
Interview questions about producers and consumers (important)
你开发数据API最快多长时间?我1分钟就足够了
VMWare网络模式-桥接,Host-Only,NAT网络
Leetcode 213: 打家劫舍 II
PAT甲级真题1166
Map interface and method
docker建立mysql:5.7版本指定路径挂载不上。
URL programming
Summary of abnormal mechanism of interview
随机推荐
Use of file class
Use of framework
SQL create temporary table
[solved] win10 cannot find a solution to the local group policy editor
Common APIs
SecureCRT取消Session记录的密码
Advanced API (multithreading)
高并发内存池
Leetcode 198: 打家劫舍
Vertx's responsive MySQL template
[set theory] order relation (partial order relation | partial order set | example of partial order set)
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
GStreamer ffmpeg avdec decoded data flow analysis
Advanced API (serialization & deserialization)
Raspberry pie update tool chain
"Moss ma not found" solution
Margin left: -100% understanding in the Grail layout
Sorting, dichotomy
Comparison of advantages and disadvantages between most complete SQL and NoSQL
论文学习——鄱阳湖星子站水位时间序列相似度研究