当前位置:网站首页>[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
边栏推荐
- Unified handling and interception of exception exceptions of vertx
- Use of file class
- SQL create temporary table
- Raspberry pie update tool chain
- When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
- 最全SQL与NoSQL优缺点对比
- Topic | synchronous asynchronous
- 3311. 最长算术
- Jeecg menu path display problem
- Leetcode 198: 打家劫舍
猜你喜欢

How long is the fastest time you can develop data API? One minute is enough for me

Common architectures of IO streams

Wireshark software usage

最全SQL与NoSQL优缺点对比

JS monitors empty objects and empty references

Discussion on some problems of array

Map interface and method
![[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)](/img/d8/b4f39d9637c9886a8c81ca125d6944.jpg)
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)

691. 立方体IV

File operation serialization recursive copy
随机推荐
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
OSI knowledge sorting
Advanced API (local simulation download file)
Discussion on some problems of array
3311. 最长算术
SecureCRT password to cancel session recording
Arduino Serial系列函数 有关print read 的总结
"Baidu Cup" CTF game 2017 February, Web: blast-1
Mail sending of vertx
JUnit unit test of vertx
C代码生产YUV420 planar格式文件
[set theory] order relation (partial order relation | partial order set | example of partial order set)
Summary of abnormal mechanism of interview
High concurrency memory pool
Vertx metric Prometheus monitoring indicators
The underlying mechanism of advertising on websites
Industrial resilience
Jeecg request URL signature
【最詳細】最新最全Redis面試大全(50道)
2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log