RoKiSim 应用及其接口开发

目录 Content
[hide]

RoKiSim 是位于加拿大蒙特利尔 ETS 控制和机器人技术实验室开发的一款多平台6轴串联机器人教育软件。使用者可以用关节模式和直角坐标系模式来移动机器人,可以参照和显示TOOL坐标系、BASE坐标系、WORLD坐标系等。机器人模型包括了几种常见的品牌型号。具体请参阅官方网址 http://www.parallemic.org/RoKiSim.html 介绍。

界面操作

RoKiSim我们先回顾下本软件的不常见的操作选项(常见的和能找到的操作方式就不提了):

  • 改变背景颜色 shift+B
  • 改变坐标系尺寸 shift+F
  • 更细腻渲染 shift+N
  • 改变TCP轨迹显示方式 shift+P
  • 改变TCP轨迹点的坐标尺寸 shift+S
  • 改变TCP轨迹点的颜色 shift+G

外部接口

此软件对于想了解机器人的运动学模型非常有帮助,使用者可以在输入相关数据,然后摇动机器人,就可以看到效果。软件本身附带了一个WII接口,可以使用WII来摇动机器人。

那么还有其他方式来摇动机器人么?或者说这个软件有没有通讯接口呢 ?带着这个问题,我按网页上的邮件地址给 Ilian 写了封邮件询问是否还有其他的通讯接口方式。Ilian 回复了邮件,并且提供了非常有用的信息。

Hello,

Here is what Albert, the programmer of RoKiSim recently replied to a similar question. I hope this helps.

Ilian

Albert’s message:
—————————————————————————————————————–

This is possible through internal socket messaging (ip 127.0.0.1, port 2001).

You can constantly send binary data through this port (joint values) and the robot will move. I’m sending you a small toolbox for Matlab that lets you control Rokisim and play simulations. This is also the way that Robtargets/Paths work in Rokisim.

It would not be difficult to do something similar using C++.

You can start by trying to copy the next table and paste it to rokisim (to paste it, select the body of main mindow and press CTRL+V):
(it also works from an excel sheet)
0 -90  90  0    0    0
10 -80 100 40   50   60
40 -70 110 70   80   90
-40 -10  50 20 -100 -150
You can control the simulation using the simulation panel (F5).

Furthermore, you can also work with a 7xN table, using the first value as an instruction. Here is another example that you can copy-paste in Rokisim with the KUKA KR 270 robot:
4  500.000  500.000  500.000    0.000    0.000    0.785
5  250.000    0.000    0.000   -1.571    0.000   -3.142
1   47.840  -73.440  111.310   60.930  -58.000  -43.620
2  -51.580  -68.140  103.880  -65.140  -59.710   47.430
Instruction 4 sets the base frame (example: [4 tx ty tz rx ry rz], in mm and radians) , instruction 5 sets the tool frame using the same method.
Instruction 1 makes a joint movement (example: [1 q1 q2 q3 q4 q5 q6] where qi are the joint angles in degrees). Finally, instruction 2 makes a linear movement.

If you have one or more objects, the first object will be placed at the base frame (work object).
If instead of instruction 4, you send instruction 4.01, this will place the second object, if it is 4.02, the third, etc. So this feature lets you place up to 100 different objects through Matlab, 4.00 being the work object.

All this COPY-PASTE can be replaced by internal TCP/IP socket data transfer.

I’m attaching this toolbox as well as an example of how to use it (RoKiSim_Demo_Example).

You can finally save your demonstration (6xN or 7xN table) in a .rks.sim file and open it using “Load a Simulation”. There must be an .rks file in the same folder to set the station.

—————————————————————————————————————–

深入求解

LT 采用 write QByteArray 的方式对 127.0.0.1:2001 发送数据,但是发现软件会死掉,显然格式不对,于是又写邮件给 Ilian ,并请 Ilian 转发给软件作者 Albert。很快就有了回信。

Dear Tao,

The communication must be done using binary data.
I’m attaching a function that will work using a binary transfer.
Nice try though 😉

Let me know if it does not work.

Albert

bool Rokisim_Send_Sequence(double joints[6]){
QTcpSocket socket;
socket.connectToHost(“localhost”, 2001);
if (!socket.waitForConnected(3000)){
QMessageBox::information(0,”Error”,”Could not connect to rokisim, start rokisim manually”);
return false;
}
quint32 size1 = 6;// 6 pour liste de joints, 7 pour des instructions
quint32 size2 = 1;
if (size1*size2 == 0){
return false;
}
QDataStream out(&socket);
out << size1;
out << size2;
for (int j=0; j<6; j++){
out << (double) joints[j];
}
if (!socket.waitForBytesWritten(5000)){
QMessageBox::information(0,”Error”,”Could not send data”);
return false;
}
socket.disconnectFromHost();
return true;
}

原来需要用 binary的方式写入才行。试用 Albert 提供的示例代码,证实完全可以工作。经过多次与两位老外网友的通信,觉得他们挺友好的。

举例来说,如果要把 [10,-90,90,0,0,0] 六个关节数据写给 RoKiSim,那么发送出的数据是

00 00 00 06 00 00 00 01 40 24 00 00 00 00 00 00 C0 56 80 00 00 00 00 00 40 56 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 

用途扩展

现在清楚了RoKiSim的接口协议,那么我们完全可以自己开发程序,比如用机器人厂家自己的SDK获取机器人的相关数据,然后发送给RoKiSim,就可以在RoKiSim中显示机器人的相关运动和姿态了。

其他

因为官方安装版需要管理员权限,所以将安装后的目录单独保留出来,需要的可以从这里下载(RoKiSim 1.7 解压版

扩展阅读

7 thoughts on “RoKiSim 应用及其接口开发

  1. 这就是你某条微博提到的支持Python的仿真软件吗?那个接受二进制输入的接口听上去挺好。

  2. Hello LT,
    我正在尝试用Matlab发送6轴机器人的关节数据给Rokisim,问题是TCP/IP建立成功,数据发送也显示成功,但是Rokisim里面的机器人的关节数据没有变化,请教是什么原因造成的?谢谢。
    PS:
    Matlab命令如下:
    t=tcpip(‘127.0.0.1’,2001);
    fopen(t);
    data=[100.0 0.5 0.8 10.1 1.2 0.6];
    fwrite(t,data);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.