龙空技术网

Flexsim案例十|运动学(一)

LearningYard学苑 432

前言:

如今各位老铁们对“运动学模型如何建立”都比较关心,你们都需要了解一些“运动学模型如何建立”的相关资讯。那么小编在网络上网罗了一些对于“运动学模型如何建立””的相关知识,希望小伙伴们能喜欢,我们快快来了解一下吧!

如何给固定资源类实体添加运动学?

如何通过运动学实现实体的移动?

一、问题描述

在这个模型中,把处理器设置成一台离心机,在处理临时实体的过程中,快速旋转。

二、模型总体布局

三、参数设置

第一步:创建实体

按照下图中的布局,向 3D 建模区中拖拽实体。

按照图中的顺序连接实体:

Source1连接到Queue2连接到Conveyor4连接到Processor3连接到Conveyor5连接到Sink6。

第二步: 添加 Kinematics(运动学)标签

运动学需要有一个用来储存信息的节点。最简单的方式就是创建一个专用于运动学的文本标签。

另外一种方式就是给实体的 variables 节点添加一个节点,使用getvarnode 命令替换所有的标签命令。

打开 Processor 的属性窗口。

打开标签选项卡。

点击 Add Text Label(添加文本标签)并重命名为"kin"来添加一个文本标签。

警告:不要尝试在属性窗口中删除 kinematics 节点。根据下面的说明修改 kinematic 的参数。手动删除可能会使程序瘫痪。

第三步: 添加自定义绘图代码(Custom Draw Code)

随着模型运行,kinematics 会不断更新

 点击触发器选项卡。

 点击自定义绘图代码触发器旁边的编辑代码按钮。

 输入以下代码:

updatekinematics(label(current, "kin"), current);

点击确定,关闭代码编辑窗口。

第四步:当加工结束时更新 Kinematics

在完成加工时,我们将最终更新 kinematics。这能确保,在不考虑3D视图的framerate(用于决定 Custom Draw Trigger 触发的频率)的情况下,或者不管是否由 3D 视图打开,kinematic都会更新到它的最终位置/旋转角度。

 在触发器选项卡上,点击加工结束触发旁边的 按钮

 复制自定义绘图触发器中的 updatekinematics 命令:

updatekinematics(label(current, "kin"), current);

点击确定,应用并关闭代码编辑窗口。

第五步:添加 OnReset(重置)代码

当模型重置时,实体返回最初位置。

在触发器选项卡上,点击重置触发器旁边的代码编辑按钮。

使用 initkinematics 命令,其中的节点参数就是刚才创建的文本标签。然后,切换到属性窗口的常规选项卡,查看实体在 x,y,z 轴的坐标值和旋转角度。把相应的值输入到 initkinematics 命令中。(处理器的旋转值默认为0)。

initkinematics(label(current, "kin"), x, y, z, 0, 0, 0, 0, 0);

注意:最后的两个参数分别代表旋转管理(rotation management)和本地坐标(local coordinates)。当把旋转管理设置成 1 时,它的“头”(对准正 x 轴方向)将向行走的方向旋转。如果 local coordinates 设置成 1,那么它将使用当前实体上级实体的坐标,而不是模型坐标。

点击确定,应用并关闭代码编辑窗口。

第六步:预置结束时更新 Kinematics

在 kinematic 开始时,实体返回它的原始状态。我们现在将添加kinematic信息,用来移动实体。

 在触发器选项卡上,点击预置结束触发器旁边的 按钮。

 复制 initkinematics 命令,它的参数和预置触发器中的相同。

 输入下面的代码:

addkinematic(label(current, "kin"), 0, 0, 3240, 360, 90, 180, 0, 0, time(), 2);

在addkinematic命令中,把x,y,z参数分别设置成0,0和3240。这个旋转动作将沿着z轴旋转3240度(9圈)。目标速度(最大速度)为360度/秒,加速度为90度/秒/秒,减速度为180度/秒/秒。起始速度和结束速度为0。开始时间是调用此命令的时间,所以我们使用time()命令。因为是旋转的动作,所以把最后一个参数设置为2或者KINEMATIC_ROTATE(对于移动操作,我们设置为1或者KINEMATIC_TRAVEL)。

点击确定,应用并关闭属性窗口。

重置并运行模型,你应该看到处理器加速、旋转、减速、停止。你可能会注意到如果在kienmatics 结束之前,开始对下一个临时实体进行加工,那么实体会马上按照 Initikinematics参数重置自己的位置。我们下一步中,将把加工时间和 kinematic 的时间进行匹配。

How to add kinematics to fixed resource entities?

How to realize the movement of entities through kinematics?

1. Problem description

In this model, the processor is set up as a centrifuge, which spins quickly during the process of processing the flowitems.

2. The overall layout of the model

3. parameter setting

Step 1: Create an entity

According to the layout in the figure below, drag entities to the 3D modeling area.

Connect the entities in the order in the figure:

Source1 connects to Queue2 connects to Conveyor4 connects to Processor3 connects to Conveyor5 connects to Sink6.

Step 2: Add the Kinematics label

Kinematics requires a node to store information. The easiest way is to create a text label dedicated to kinematics.

Another way is to add a node to the variables node of the entity, and use the getvarnode command to replace all label commands.

Open the properties window of the Processor.

Open the label tab.

Click Add Text Label and rename it to "kin" to add a text label.

Warning: Do not try to delete the kinematics node in the properties window. Modify the parameters of kinematic according to the following instructions. Manual deletion may paralyze the program.

Step 3: Add Custom Draw Code

As the model runs, kinematics will continue to update

• Click the Trigger tab.

• Click the edit code button next to the custom drawing code trigger.

• Enter the following code:

updatekinematics(label(current, "kin"), current);

Click OK to close the code editing window.

Step 4: Update Kinematics when processing is finished

When the processing is completed, we will finally update the kinematics. This ensures that the kinematic will update to its final position/rotation angle regardless of the framerate of the 3D view (used to determine the frequency of Custom Draw Trigger triggering), or regardless of whether the 3D view is open or not.

• On the trigger tab, click the button next to the processing end trigger

• Copy the updatekinematics command in the custom drawing trigger:

updatekinematics(label(current, "kin"), current);

Click OK to apply and close the code editing window.

Step 5: Add OnReset (reset) code

When the model is reset, the entity returns to its original position.

On the Trigger tab, click the code edit button next to Reset Trigger.

Use the initkinematics command, where the node parameter is the text label just created. Then, switch to the general tab of the properties window to view the coordinate value and rotation angle of the entity on the x, y, and z axes. Enter the corresponding value into the initkinematics command. (The rotation value of the processor defaults to 0).

initkinematics(label(current, "kin"), x, y, z, 0, 0, 0, 0, 0);

Note: The last two parameters represent rotation management and local coordinates respectively. When the rotation management is set to 1, its "head" (aligned to the positive x-axis direction) will rotate in the direction of walking. If local coordinates is set to 1, then it will use the coordinates of the current entity's parent entity instead of the model coordinates.

Click OK to apply and close the code editing window.

Step 6: Update Kinematics at the end of the preset

At the beginning of kinematic, the entity returns to its original state. We will now add kinematic information to move entities.

• On the Trigger tab, click the button next to the preset end trigger.

• Copy the initkinematics command, its parameters are the same as those in the preset trigger.

• Enter the following code:

addkinematic(label(current, "kin"), 0, 0, 3240, 360, 90, 180, 0, 0, time(), 2);

In the addkinematic command, set the x, y, and z parameters to 0, 0, and 3240, respectively. This rotation will rotate 3240 degrees (9 revolutions) along the z axis. The target speed (maximum speed) is 360 degrees/sec, the acceleration is 90 degrees/sec/sec, and the deceleration is 180 degrees/sec/sec. The start speed and end speed are 0. The start time is the time when this command is called, so we use the time() command. Because it is a rotating action, set the last parameter to 2 or KINEMATIC_ROTATE (for moving operations, we set it to 1 or KINEMATIC_TRAVEL).

Click OK to apply and close the properties window.

Reset and run the model, you should see the processor speed up, spin, slow down, and stop. You may notice that if you start processing the next flowitem before the end of kienmatics, the entity will immediately reset its position according to the Initikinematics parameters. In our next step, we will match the processing time with the kinematic time.

注:本模型使用的是FlexSim 2019

参考资料:百度百科,Flexsim7.5.4版本中文用户手册【北京创时能公司汉化】版

翻译:Google翻译

本文由LearningYard学苑原创,文中部分图片和文字均来源于网络,如有侵权请联系删除!

标签: #运动学模型如何建立 #运动学建模方法