活动#

何时开始#

启动时块用于在项目启动时运行附加的块堆栈。

当开始

当项目从 VEXcode Blocks 中的开始按钮启动时,将运行“启动时”事件。

所有新项目将自动包含“启动时”块。

在此示例中,6 轴臂将移动到坐标 (120, 120, 75)(以毫米为单位)。

当开始
移动 [手臂 v] 到位置x:(120) y:(120) z:(75) [毫米 v] ▶

当计时器#

当大脑的计时器等于给定值时,当计时器块用于运行附加的块堆栈。

当计时器> (1) 秒

大脑的计时器在每个项目开始时或每次重置大脑的计时器时启动。

选择时间量。当 Brain 的计时器达到输入的时间量时,计时器事件就会运行。

当计时器> (3.25) 秒

在这个例子中,5秒后,机器人将把消息打印到打印控制台。

当计时器> (5) 秒
在控制台上打印 [5 seconds have passed .]▶

当我收到#

当我收到块用于在从广播消息中接收到选定的消息时运行附加的块堆栈。

当我收到 [message1 v]

选择要监听的消息。也可以创建新消息。

当接收选择时

在此示例中,代码将持续检查 6 轴机械臂是否可以在 x 轴上移动 +20 毫米。如果 6 轴机械臂可以移动该距离,则会广播一条消息,指示其移动该距离。

当开始
永久循环
[Continuously check if the Arm can move +20 mm on the x axis.]
如果 <[手臂 v] 位置增加x:(20) y:(0) z:(0) [毫米 v]?> 那么
[Every time the 6-Axis can move, broadcast the message.]
广播 [arm_can_move v]

当我收到 [arm_can_move v]
[When the message is received, move the Arm +20 mm on the x axis.]
[手臂 v] 位置递增x:(20) y:(0) z:(0) [毫米 v] ▶

播送#

广播块用于广播消息,以激活任何以当我收到块开头的堆栈,监听广播的消息。

广播 (message1 v)

发送广播的堆栈将与接收广播消息的其他堆栈同时继续运行块。

选择要广播的消息。也可以创建新消息。

广播选择

在此示例中,代码将持续检查 6 轴机械臂是否可以在 x 轴上移动 +20 毫米。如果 6 轴机械臂可以移动该距离,则会广播一条消息,指示其移动该距离。

当开始
永久循环
[Continuously check if the Arm can move +20 mm on the x axis.]
如果 <[手臂 v] 位置增加x:(20) y:(0) z:(0) [毫米 v]?> 那么
[Every time the 6-Axis Arm can move, broadcast the message.]
广播 [arm_can_move v]

当我收到 [arm_can_move v]
[When the message is received, move the Arm +20 mm on the x axis.]
[手臂 v] 位置递增x:(20) y:(0) z:(0) [毫米 v] ▶

广播并等待#

广播和等待块用于广播消息以激活任何以当我收到块开头的堆栈,监听广播的消息,同时暂停堆栈的其余部分。

该块广播一条消息以激活以“当我收到块时”开头的任何堆栈,该块监听广播的消息,同时暂停堆栈的其余部分。

广播 (message1 v) 并等待

发送广播并等待的堆栈将暂停,直到接收广播消息的其他堆栈完成。

选择要广播的消息。也可以创建新消息。

广播_等待_选择

在此示例中,代码将持续检查 6 轴机械臂是否可以在 x 轴上移动 +20 毫米。如果 6 轴机械臂可以移动该距离,则会广播一条消息,指示其移动该距离。

当开始
永久循环
[Continuously check if the Arm can move +20 mm on the x axis.]
如果 <[手臂 v] 位置增加x:(20) y:(0) z:(0) [毫米 v]?> 那么
[Every time the 6-Axis Arm can move, broadcast the message.]
广播 [arm_can_move v] 并等待

当我收到 [arm_can_move v]
[When the message is received, move the Arm +20 mm on the x axis.]
[手臂 v] 位置递增x:(20) y:(0) z:(0) [毫米 v] ▶