博客banner-02

从仿真到实践:三自由度串联机器人的运动控制与实验 From simulation to practice: Motion control and experiment of a 3 DOF serial robot arm

【简介】
三自由度串联机器人是机械原理、机器人等课程中的常见学习研究对象,而小型化、桌面化的机器人、机械臂提供了更多实践与分析的可能。本文结合机械运动理论、软件仿真与机器人硬件实验,探索了三自由度串联机器人的运动控制,实现了桌面型机械臂的轨迹运动控制。整体过程从理论原理、到软件操作、再到编程实现,原理清晰、简明流畅、易于实现,适合于有一定基础的学习者或兴趣爱好者进行学习、实验,也可以基于现有的实验结果,作进一步的探索。

【基础准备 Preparation】
1.uArm机械臂 The uArm

uArm机械臂是一款开源的桌面型多自由度串联机械臂,它的原型与原理与很多工业机器人类似,它小巧、灵活、可扩展性好,很方便用于机械人实验。我们基于Uarm机械臂进行本次实验探索。
The uArm is a desktop open-source multiple DOF serial robot arm, it is similar to many industry robot which is small, flexible, good scalability and easy to be sued in experiment. Our research is bead on Uarm.

2.MapleSim软件 The MapleSim

MapleSim是一款多领域系统级仿真建模软件,它在汽车、航空航天、机器人等专业领域都有许多应用。本次实验中,我们使用Maple & MapleSim建立机械臂的模型、并进行仿真、求解,并将体验其在“理论分析-软件仿真-硬件实现”整个流程中的特性与优势所在。
MapleSim is a cross-platfom system-level simulation software. It has been widely used in the area of automobile, aerospace and robotics. In this experiment, we will use Maple& MapleSime to build the robot arm model and then simulate. This will reflect the MapleSim advantages of the process “Theory analysis, software simulation and hardware realization”.

【1.建立运动学模型】

uArm Metal型号的机械臂实物如下图,其中我们卸掉了“机械手”部分的气动吸盘,改用其配套的笔夹,并最终希望通过夹持毛笔进行作画、写字等轨迹运动的控制。
uArm metal is illustrated below and we have already take off the pump in the end-effector and replace it to a pen-holder. We will use pen-holder to hold a brush pen to draw, write and move in a certain path.

1
图1 安装了笔夹的uArm Metal机械臂
Figure 1: uArm metal robot arm with pen-holder

我们针对以上Uarm机械臂,建立其运动学模型,以方便后续的实验研究。
在MapleSim软件中建立机械臂模型,一方面,我们可以使用Ufactory公司提供的机械臂CAD文件,建立详细的三维机械模型。如下列图所示:
Based on uArm robot arm, we establish the kinematics model. In MapleSim, a detailed robot model is built firstly based the CAD file of uarm from Ufactory company. The relevant diagram is shown below:

2
图2-a 导入CAD文件,基座部分
Figure 2-a, import CAD file of robot arm base

3
图2-b 机械臂建模-运动机构部分
Figure 2-b robot arm simulation and mechanism

4
图3-c 对应的三维多体模型
Figure 3-c 3D model of uarm

以上详细模型中,加载了各个CAD机械结构的质量、质心、旋转惯量,可用于进一步的动力学仿真,其几何尺寸也更加精确。
Based the model above, the mass, centroid, rotary inertia of mechanical structure are also loaded into the software which would be useful for further simulation.

另一方面,我们可以基于机械原理,建立简化的机械臂模型,如下列图所示:
In another aspect, we can build the simpler robot arm model based the mechanical theory as shown below:

5
图4-a 简化的MapleSim机械臂运动学模型
Figure 4-a Simplified kinematics model in MapleSim

6
图4-b 对应的三维多体模型
Figure 4-b The corresponding 3D multi-body model

上图中将三自由度串联机械臂简化为由二力杆、旋转副组成的机构,其中各部分机械结构的几何尺寸需要进行测量,R1、R2、R3对应Uarm机械臂中三个舵机的控制角度。


【2 逆向运动学求解Solve inverse kinematics】

我们希望通过控制Uarm机械臂的三个舵机的角度,来实现机械臂终端的三维空间XYZ坐标的轨迹控制,这就需要进行逆向运动学求解。
We would like to control the 3 servos’ angle to control the end-effector to move in the 3D space XYZ. The inverse kinematics would be needed for this process.

在MapleSim模型中调用Maple分析模版进行机械臂的逆向运动学求解,其中只需要通过一个函数命令,直接获取终端与基座的运动学约束方程:
In MapleSim, we can directly invoke the Maple analysis pattern to acquire the inverse kinematics solution by typing a single function. A constrain function between base and end-effector would be generated then.

7
图5 使用Maple函数直接获取终端与基座之间的运动学约束方程
Figure 5. Use Maple function can obtain the kinematics function between end-effector and base

在Maple/MapleSim中可以直接运用以上符号化的方程公式,建立对三个舵机角度控制的元件,新的整体模型如下:
We can use the the formula to model the movement of robot arm and control the 3 servos in Maple/MapleSim.

8
图6 带运动学控制的机械臂模型
Figure 6. Robot arm with

此处,一方面我们可以直接在Maple中对以上约束方程进行求解,求得三个表达式X=f(R1,R2,R3) , Y=g(R1,R2,R3) , Z=h(R2,R3),并在Maple中转化为C++语言,直接加载到Uarm机械臂的Arduino芯片中。另一方面,我们也可以在软件中完成仿真,获取仿真结果中的R1、R2、R3数据表,直接在Arudino芯片中控制舵机角度。第二种方法对于编程的要求更低,而且可以在软件中自动处理圆弧插补的问题,简化一次实验中的整体工作量。后文中我们采用第二种方法。
After this , a solution can be obtained from Maple to solve that constrains and get X=f(R1,R2,R3) , Y=g(R1,R2,R3) , Z=h(R2,R3). After transferring the code to C++, it can be downloaded into the Arduino Chip in Uarm. In another hand, we can get solution of R1, R2 and R3 from simulation in Maple and this is more reliable way to auto process the circular interpolation problems, so we will use this way afterwards.

【3.轨迹规划 Trajectory generation】
实验的初步目的,希望能控制机械臂夹持毛笔进行预订轨迹的绘画、写字。例如若需要绘制一张图片的轮廓,可以用Maple编写一段图像处理程序,得到一组轮廓的数据表,然后以此作为控制的目标,但是这要求一定的编程能力。
The initial goal of this experiment is to use robot arm to draw and write. For example, by given a picture of contour lines, Maple can automatically generate a code to describe the contour lines of this picture and draw.

9
图7-a 图像处理图片-二值化
Figure 7-a Image Processing: Binarization

10
图7-b Maple中图像处理程序-关键部分
Firgure 7-b 7-b Maple Program

11
图7-c 图像处理结果-数据表
Figure7-c Dataset in Image Processing

而若是只进行英文单词、中文汉字的书写,其轨迹规划将要简单很多,如下:
我们按照需要书写的文字,编写一个其轨迹的电子表格:
If we only need English or Chinese letter writing, the trajectory would be much easier as shown below:

maple
图8 预想书写文字的轨迹电子表格-使用24个点表示MAPLE五个字母
Figure 8 Use 24 points to represent 5 letters

例如上图,可以使用几十个坐标点,来表示5个英文字母“M A P L E”,并添加一列等差的时间轴数列,将这个电子表格文件作为机械臂模型的XYZ目标输入。
As shown above, by using dozens of coordinates to represent 5 letters ‘MAPPLE ‘ and add a serial of array of time, the robot arm can use this coordinates as the input.

注意到这个数据表是离散的,并且时间轴的间隔比较大,而在MapleSim中导入这个离散的数据表后,可以自动的采用插值方法进行处理,包括线性插值、一阶可导插值等,省略了考虑圆弧插补的问题。
To be noticed that, the data is discrete and has a huge gap between them. But in Maple, the interpolation data can be import to solve this issue.

【4.仿真结果与控制代码】
基于以上建立的机械-控制器模型,和轨迹规划后的XYZ目标输入,在MapleSim中仿真,得到如下结果,包括三维多体动画和R1、R2、R3角度结果数据表:
Based on the model described above, we can obtain the results in the MapleSim simulation and get 3D simulation and servo angles of R1, R2 and R3 respectively.

13
图9 仿真结果-三维多体动画和三关节角度数据表
Figure 9. Simulation result and angle dataset.

导出三关节角度数据表后,平均地取400个点,并转化为CSV格式,如下列图:
After exporting the data of three servo angles and getting average 400 points, the CSV version of data will be transferred as below:

14
图10-a 仿真结果-CSV数据表
Figure 10-a Simulation data set in CSV file

15
图10-b Arduino程序-for循环
Figure 10-b Arduino program

并在Arduino软件中写一个简单的for循环程序,等时差地历遍这些数据点,用Uarm库中预设的uarm.writeAngel 函数对三个关节角度进行控制。
In arduino, we will write a simple for loop program to traverse all these points and control uarm with these porint by using uarm.writeAngle function to control 3 servo angles.

【5 实验结果与展望 Experiment Result and Expectation】

简单地完善Arduino程序后,加载到Uarm中,进行硬件实验,绘图的结果如下
By executing Arduino Program into uarm, the graphic result will be plotted below:

16
图11 硬件实验结果-绘图“枫叶-笑脸”图片
Figure 11: Hardware experiment: Maple-leaf smiling face Drawing

相关的实验结果视频可以参考链接: http://pan.baidu.com/s/1bpofQ0n 密码: gsm5
Relevant experiment results and videos can be found in: http://pan.baidu.com/s/1bpofQ0n Password: gsm5

到此,我们就基本上完成了本次实验内容。
So far, we have accomplished our experiment.

进一步,我们可以建立机器人的电机模型、电路模型,进行参数标定、动力学仿真,实现机器人更高精度的控制,或者用于指导新的机器人的结构、控制算法的设计。总的来看,以上实验内容即包括软件建模仿真、又完成了硬件实现,通过整个流程可以完成初步的对于机器人的学习。并且基于软件仿真的发散性、和桌面型机械臂的低成本、灵活性,可以探索、研究更多、更深的机械、控制、机器人课程的内容。
Further more, we can establish the motor, circuit model and simulate the dynamics to achieve higher accuracy control. Or we can use this to design the new structure and control algorithm.

—————————————————————————————————————————
本文由Maplesoft团队原创,UFACTORY团队翻译。如需转载,请注明出处。
欢迎分享你的uArm项目,投稿请发邮件至:info@ufactory.cc。

The blog is written by the Maplesoft team and translated by the UFACTORY team. If you want to reprint it, please indicate proper attribution.
To share your projects, please contact us at info@ufactory.cc.

No Comments

Leave a Comment