当前位置:网站首页>[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
边栏推荐
- 《指环王:力量之戒》新剧照 力量之戒铸造者亮相
- sharepoint 2007 versions
- 【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
- Hisat2 - stringtie - deseq2 pipeline for bulk RNA seq
- Qtip2 solves the problem of too many texts
- Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
- Various postures of CS without online line
- Custom generic structure
- The babbage industrial policy forum
- Visit Google homepage to display this page, which cannot be displayed
猜你喜欢

Recursion, Fibonacci sequence

Why is data service the direction of the next generation data center?

Map interface and method

3311. 最长算术

Leetcode 198: 打家劫舍

Comparison of advantages and disadvantages between most complete SQL and NoSQL

Basic knowledge about SQL database

Store WordPress media content on 4everland to complete decentralized storage

FileInputStream and fileoutputstream

【已解决】Unknown error 1146
随机推荐
Chrome 98 Private Network Access problem w/ disabled web security: Request had no target IP address
Introduction of buffer flow
【无标题】
VMware network mode - bridge, host only, NAT network
The babbage industrial policy forum
Le Seigneur des anneaux: l'anneau du pouvoir
Advanced APL (realize group chat room)
Leetcode 213: 打家劫舍 II
【最詳細】最新最全Redis面試大全(50道)
专题 | 同步 异步
JS monitors empty objects and empty references
I. D3.js hello world
OSI knowledge sorting
Hisat2 - stringtie - deseq2 pipeline for bulk RNA seq
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
Advanced API (use of file class)
2021-07-18
【已解决】Unknown error 1146
Common problems in io streams
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.