Skip to content
🔐

專班教材存取限制

請輸入授權密碼以繼續閱覽

2. Software Fluency

You should already know the basic software operations from the basic lessons. In this intermediate lesson, we will move faster and cover more competition-essential operations. If you get comfortable with all of these, you should be able to get a good result in the preliminaries.

Variables

To create variables in a project, go to AdministratorVariable at the top of the screen to open variable management. Note that all variables we create should be Project Variables. Be careful not to create Global Variables and pollute the names.

On the Project VariablesVariables page, you can create a variable. There are many variable types. Use the Type dropdown to choose a data type. Programmers should find this familiar, but if you have never programmed before, do not panic. Most of the time, our variables are only for counting, so just choose int. The Name also follows programming naming rules: use only English letters, numbers, and underscores, and no spaces. The final Value is optional. If left blank, it defaults to 0 for int, so for counting you do not need to enter anything. After filling this in, remember to click Add; only then is the variable created. After that, close the variable management page.

Display

As the name suggests, Display shows information. It is a bit like an output function in traditional programming languages.

The settings are mostly intuitive. Text Color and Background Color do not need much explanation, and competitions usually do not focus on them. Title and Content are more special. Normal text must be wrapped in ", and variables are connected with +. Variables or special text such as newline can be inserted using the pencil beside Content. These elements are connected with +.

For example, if I want to output the values of variables a, b, and c on three lines, I can write Content as:

text
"a: " + var_a + newline + "b: " + var_b + newline + "c: " + var_c

Small Tip

Although Display is very flexible, competitions usually only ask for something like "output this information", so do not get too obsessed with formatting.

Set (Variables)

We already learned how to use Set to control the gripper. In this chapter, we use Set to control variables.

In the Set editor, click Select next to Variable, then click Add variable control icon at the top of the variable settings window that appears on the right. A new Expression Editor window appears. Choose the Variable category on the left, then use Insert to insert variables into the input box on the right.

The right side has three boxes: the operated value at the top, the operator in the middle, and the operand at the bottom. Together, they form an expression, just like variable control in programming. For example, if I want to set variable a to 0, insert var_a at the top, choose = in the middle, and enter 0 at the bottom. If I want to add one to a, insert var_a, choose +=, and enter 1.

After setting it, click OK to save. Variable control is done, and you can close the Set settings window.

Small Tip

The Constants, Functions, and Math categories also provide many built-in values or functions. Try them when you have time. This textbook will not introduce them in detail.

Also, Set can control several things at once, such as two variables, or a variable and the end module. Use Add variable control icon to create more than one setting, and one Set can control more than one action.

If

After learning to create and control variables, we need the machine to run different tasks according to different variable states. To let the machine judge variable states, we use If.

The If setup process is similar to controlling variables with Set. Open the If editor, click Select next to Variable, then click Add variable condition icon at the top of the variable settings window. A new Expression Editor appears, very similar to the Set editor. Choose the Variable category on the left, then use Insert to put variables into the input box.

The right side has three boxes: the judged value at the top, the operator in the middle, and the comparison value at the bottom. Together, they form an expression, just like judging variables in programming. For example, if I want to check whether variable a is not equal to 5, insert var_a, choose !=, and enter 5.

Small Tip

If can judge more than variables. It can also judge end module states and more. These are worth exploring, and they may appear in finals. This textbook will not introduce them in detail, but if you do not know how to operate them, use the contact information in the Site Guide.

Also, If can judge several things at once, such as two variables, or variables plus end module states. Use Add variable condition icon to create more than one condition, then choose OR or AND in Variable Judgment Rule; one If can judge more than one thing.

Gateway

Gateway is very similar to If, but it can set several branches at once. It feels a bit like switch-case in C or match-case in Python.

To set Gateway, click the pencil on the Gateway node to open its editor, then click Add condition icon to add conditions. Existing conditions appear below, and each can be configured with its own pencil icon. After all conditions are set, Gateway is ready.

Wait for (Variables)

Besides waiting for time, Wait for can also wait until a condition is true using an expression similar to If. This is usually used with hardware device states and is less commonly used for variables, so this chapter will not expand on it.

Pallet

When playing with the arm, have you ever tried to fill the little mahjong board? You will notice that doing this with only Point is extremely annoying. This is where Pallet becomes useful.

Pallet lets users align only three positions, then automatically calculates the coordinates of every point in a rectangle. For the mahjong board, the number of points you need drops from six to three, and you do not need to manually control variables and If. Very convenient.

After opening the Pallet setup page, Please select placement mode offers four modes. The icons make the modes pretty intuitive. If you are interested, try all four during free practice. The section Please teach three points to create pallet placement configuration should be set according to the relative positions shown by ①, ②, and ③ in the placement mode icon. For example, for the first mode, the board points should be upper rightupper leftlower left. Pull the arm to the three points and press Get First Point, Get Second Point, and Get Third Point.

For Rows and Columns, in the mahjong board case, enter 3 for and 2 for .

Leave the rest alone. Click OK and close the window. The Pallet node is set.

Manual-Decision

Short for M-Decision, this is one of the few functions in the flow editor that can do human-machine interaction. It lets someone choose an option while running your project and control the arm's behavior.

Several child nodes appear under M-Decision, representing different choices. However, all settings are done by clicking the pencil on the main M-Decision. Title and Content are like Display. The important part is Decision Condition Settings below, which acts as the options. Click Add option icon to add more choices, then use each option's pencil icon to configure it. Usually setting the Title is enough; it becomes the text shown for that option.

You can run the project to test M-Decision. When choosing options, click with the mouse, or use + and - on the controller to move between options and PLAY to select.

Set (Coordinate Parameterization)

We have already learned two uses of Set: controlling the end module and controlling variables. Now we look at something very similar to variables: coordinate parameterization. From the name, you can guess that it works much like variable control, except the variable is not one we created ourselves; it is a coordinate value.

Why control coordinate values? This is mainly useful when placing several workpieces in the same area. If every object is placed at exactly the same position, the result is obvious: collision. So we can move upward or sideways a little so the objects do not hit each other. No matter which direction you adjust, this uses coordinate parameterization.

In the Set settings page, choose Select for Variable and enter the same interface used for variable control. This time, open the Parameterization menu on the left. It depends on a point, meaning the point we want to offset. Use the Select menu to choose the Point to parameterize. Leave Property alone and look below at Robot Item. This controls coordinates. In the dropdown, float/Value[0] through float/Value[5] correspond to x, y, z, Rx, Ry, and Rz. For example, if we want to stack upward, choose float/Value[2], then click Insert.

The rest works like variable control. Fill the boxes with float/Value[2], +=, and 20 (unit: mm). Now coordinate parameterization is set.

A textbook for the YMSH AI program