当前位置:网站首页>[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
边栏推荐
- TypeScript let与var的区别
- pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
- Discussion on some problems of array
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- TypeScript let与var的区别
- C代码生产YUV420 planar格式文件
- Advanced API (batch image Download & socket dialog)
- Realize the reuse of components with different routing parameters and monitor the changes of routing parameters
- Talk about floating
- Take you through the whole process and comprehensively understand the software accidents that belong to testing
猜你喜欢

Interview questions about producers and consumers (important)

SecureCRT password to cancel session recording

【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘

Hash table, generic

691. Cube IV

Docker builds MySQL: the specified path of version 5.7 cannot be mounted.

Use of other streams

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

TCP cumulative acknowledgement and window value update

Take you through the whole process and comprehensively understand the software accidents that belong to testing
随机推荐
[plus de détails] dernière entrevue complète redis (50)
Sent by mqtt client server of vertx
Industrial resilience
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
Circuit, packet and message exchange
JUnit unit test of vertx
C代码生产YUV420 planar格式文件
Realize the reuse of components with different routing parameters and monitor the changes of routing parameters
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
Lombok cooperates with @slf4j and logback to realize logging
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
VMWare网络模式-桥接,Host-Only,NAT网络
[set theory] order relation (partial order relation | partial order set | example of partial order set)
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Logging log configuration of vertx
Dora (discover offer request recognition) process of obtaining IP address
3311. Longest arithmetic
FileInputStream and fileoutputstream
Responsive MySQL of vertx
Margin left: -100% understanding in the Grail layout