当前位置:网站首页>[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
边栏推荐
- Deep learning parameter initialization (I) Xavier initialization with code
- gstreamer ffmpeg avdec解码数据流向分析
- 带你全流程,全方位的了解属于测试的软件事故
- Comparison of advantages and disadvantages between most complete SQL and NoSQL
- Common APIs
- TypeScript let与var的区别
- 专题 | 同步 异步
- Hello world of vertx
- 4279. 笛卡尔树
- SecureCRT password to cancel session recording
猜你喜欢

4279. Cartesian tree

Take you through the whole process and comprehensively understand the software accidents that belong to testing

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

Introduction of buffer flow

TreeMap

Custom generic structure

7.2 brush two questions

在 4EVERLAND 上存储 WordPress 媒体内容,完成去中心化存储

Le Seigneur des anneaux: l'anneau du pouvoir

Leetcode 198: 打家劫舍
随机推荐
Store WordPress media content on 4everland to complete decentralized storage
Circuit, packet and message exchange
Le Seigneur des anneaux: l'anneau du pouvoir
Longest common prefix and
Common architectures of IO streams
docker建立mysql:5.7版本指定路径挂载不上。
Various postures of CS without online line
4279. 笛卡尔树
Advanced API (character stream & net for beginners)
【已解决】win10找不到本地组策略编辑器解决方法
在 4EVERLAND 上存储 WordPress 媒体内容,完成去中心化存储
Advanced API (use of file class)
Web router of vertx
Deep learning parameter initialization (I) Xavier initialization with code
"Moss ma not found" solution
Common operations of JSP
[solved] sqlexception: invalid value for getint() - 'Tian Peng‘
Qtip2 solves the problem of too many texts
Responsive MySQL of vertx
Common APIs