Control#
Wait#
The Wait block is used to wait for a specific amount of time before moving to the next block.
wait (1) seconds
Choose an amount of time to wait.
The wait block can accept decimals, integers, or numeric blocks.
In this example, the 6-Axis Arm’s Magnet Pickup Tool will be engaged to pick up an item before dropping the item after 1 second.
when started :: hat events
[Set the Arm and effector to Magnet and engaged.]
set [arm v] end effector to [magnet v]
set [arm v] magnet to [engaged v]
[Move the Arm lower on the z axis to the object to pick it up.]
move [arm v] to position x: (120) y: (0) z: (5) [mm v] ▶
[Move the Arm higher on the z axis to move the object.]
move [arm v] to position x: (120) y: (0) z: (100) [mm v] ▶
[Drop the item after 1 second.]
wait (1) seconds
set [arm v] magnet to [released v]
Repeat#
The Repeat C block is used to repeat the blocks contained inside for a set number of times.
repeat (10)
end
First enter a value to indicate how many times the stack will repeat the blocks contained inside.
The Repeat C block can accept integers or numeric blocks.
C blocks can also be put inside of each other. This concept is called nesting which can help save time when programming different behaviors.
In this example, the Arm will move -20 mm on the z axis twice in a row.
when started :: hat events
[Move -20 mm on the z axis twice in a row.]
repeat (2)
increment [arm v] position by x: (0) y: (0) z: (-20) [mm v] ▶
end
Forever#
The Forever C block is used to repeat any blocks contained inside forever.
forever
end
Place blocks in a Forever C block to have those actions repeat forever.
You can exit a Forever C block by placing a break block inside.
C blocks can also be put inside of each other. This concept is called nesting which can help save time when programming different behaviors.
In this example, the code will continuously check if the 6-Axis Arm can move +20 mm on the x axis. If the 6-Axis Arm can move for that distance, a message will be broadcasted to move that distance.
when started :: hat events
forever
[Continuously check if the Arm can move +20 mm on the x axis.]
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
[Every time the 6-Axis Arm can move, broadcast the message.]
broadcast [arm_can_move v]
end
end
when I receive [arm_can_move v] :: hat events
[When the message is received, move the Arm +20 mm on the x axis.]
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
If then#
The If then C block is used to run the blocks inside, if the Boolean condition reports True
.
if <> then
end
The If then C block will only check the Boolean condition once.
If the Boolean condition reports True
, the blocks inside of the C block will run.
If the Boolean condition reports False
, the blocks inside of the C block will be skipped.
The If then C block can accept hexagonal (six-sided) shaped blocks as its condition.
In this example, the code will continuously check if the 6-Axis Arm can move +20 mm on the x axis. If the 6-Axis Arm can move for that distance, a message will be broadcasted to move that distance.
when started :: hat events
forever
[Continuously check if the Arm can move +20 mm on the x axis.]
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
[Every time the 6-Axis Arm can move, broadcast the message.]
broadcast [arm_can_move v]
end
end
when I receive [arm_can_move v] :: hat events
[When the message is received, move the Arm +20 mm on the x axis.]
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
If then else#
The If then else C block is used to run the blocks inside the first or second parts of the if then else, based on the Boolean value reported.
if <> then
else
end
The If then else C block will only check the Boolean condition once.
If the Boolean condition reports True
, the blocks inside of the if section will be run.
If the Boolean condition reports False
, the blocks inside of the else section will be run.
The If then else C block can accept hexagonal (six-sided) shaped blocks as its condition.
In this example, the code will continuously check if the 6-Axis Arm can move +20 mm on the x axis. If the 6-Axis Arm can move for that distance, a message will be broadcasted to move that distance. If the 6-Axis Arm can not move that distance, a message will be printed to the Print Console.
when started :: hat events
forever
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
else
print [Arm can no longer move +20 mm on the x axis.] ▶
end
end
If then else if then else#
The If then else if then else C block is used to run the blocks inside the first set of internal blocks in the If then else if then else C block where the condition returns True
.
if <> then
else if <> then
else
end
The If then else if then else C block will only check the Boolean condition once.
If the Boolean condition reports True
, the blocks inside the if section will run.
If the Boolean condition reports False
, the If then else if then else C block will check the first of the else if lines. For each else if line, the block will check if the Boolean condition is reports True
. If it is true, the internal blocks directly under that line will run before continuing on to the next block under the If then else if then else C block.
If all the Boolean conditions for the else if lines report False
, the blocks inside of the else section will be run.
The If then else if then else C block can accept hexagonal (six-sided) shaped blocks as its condition.
To add another else if condition, click on the + on the else line. This will add a new else if condition to the bottom of the current list.
To remove an else if condition, click on the - on the else line. This will remove the last else if condition line, but will not delete any used blocks in the condition.
In this example, the code will continuously check if the 6-Axis Arm can move +20 mm on the x axis. If the 6-Axis Arm can move for that distance, a message will be broadcasted to move that distance. If the 6-Axis Arm can not move that distance, it will then check if it can move +20 mm on the y axis and do so if possible. The 6-Axis Arm will continue to move until it can’t, and then print a message.
when started :: hat events
forever
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
else if <[arm v] increment position by x: (0) y: (20) z: (0) [mm v]?> then
increment [arm v] position by x: (0) y: (20) z: (0) [mm v] ▶
else
print [Arm can no longer move +20 mm on the x or y axes.] ▶
end
end
Wait until#
The Wait until block is used to wait for a Boolean block to report True
before moving to the next block.
wait until <>
The Wait until block will repeatedly check a Boolean reporter block and will not move to the next block until the Boolean report block reports True
.
The Wait until Boolean block can accept hexagonal (six-sided) shaped blocks.
In this example, the 6-Axis Arm will move down the z axis, and will set the Magnet Pickup Tool to engaged once the 6-Axis Arm’s position is lower than 20 mm on the z axis.
when started :: hat events
set [arm v] end effector to [magnet v]
move [arm v] to position x: (120) y: (0) z: (5) [mm v] ◀ and don't wait
wait until <([arm v] position [z v] in [mm v]) < (20)>
set [arm v] magnet to [engaged v]
Repeat until#
The Repeat until C block is used to repeat the blocks inside until the Boolean condition reports True
.
repeat until <>
end
The Repeat until C block will only check the Boolean condition at the beginning of each loop.
If the Boolean condition reports False
, the blocks inside of the block will run.
If the Boolean condition reports True
, the blocks inside of the block will be skipped.
The Repeat until
C block can accept hexagonal (six-sided) shaped blocks as its condition.
In this example, the 6-Axis Arm will increment move +20 mm along the x axis until it can no longer move for that distance.
when started :: hat events
repeat until <not <[arm v] increment position by x: (20) y: (0) z: (0) [mm v] ?>>
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
end
While#
The While C block is used to repeat the blocks inside while the Boolean condition reports True
.
while <>
end
The While C block will only check the Boolean condition at the beginning of each loop.
If the Boolean condition is reports True
, the blocks inside of the block will run.
If the Boolean condition is reports False
, the blocks inside of the block will be skipped.
The While C block can accept hexagonal (six-sided) shaped blocks as its condition.
In this example, the 6-Axis Arm will move to the coordinates (200, 200, 100) and will print its x position every .25 seconds as the 6-Axis Arm moves.
when started :: hat events
move [arm v] to position x: (200) y: (200) z: (100) [mm v] ◀ and don't wait
while <not <[arm v] is done moving?>>
print ([arm v] position [x v] in [mm v]) ◀ and set cursor to next row
wait (0.25) seconds
end
Break#
The Break block is used to exit a repeating loop immediately.
break
When added to a repeating C block, the Break block will exit the loop it is currently in.
In this example, the 6-Axis Arm will continuously check if it can increment move +20 mm on the x axis until it can’t. Once the 6-Axis Arm can no longer increment for that distance, it will break out of the loop and move to the coordinates (120, 0, 100).
when started :: hat events
forever
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
end
break
end
move [arm v] to position x: (120) y: (0) z: (100) [mm v] ▶
Stop project#
The Stop project block is used to stop a running project
stop project
In this example, the 6-Axis Arm will continuously check if it can increment move +20 mm on the x axis until it can’t. Once the 6-Axis Arm can no longer increment for that distance, the project will stop.
when started :: hat events
forever
if <[arm v] increment position by x: (20) y: (0) z: (0) [mm v]?> then
increment [arm v] position by x: (20) y: (0) z: (0) [mm v] ▶
end
stop project
end