运动#

介绍#

The VEX AIM Coding Robot uses a holonomic drivetrain to move forward, reverse, left, right, or at an angle while also being able to turn independently. Motion blocks control how the robot moves and turns, how fast it moves, and how its x and y position are tracked.

圆形罗盘刻度盘,0-315 度,环绕深灰色显示屏,搭配海军蓝色屏幕。机器人正面朝向罗盘刻度盘的 0 度。

以下是所有模块的列表:

动作——移动和转向机器人。

  • move — Moves the robot forward, reverse, left, or right forever.

  • move at angle — Moves the robot at a specific angle forever.

  • move for — 使机器人沿特定方向移动设定的距离。

  • move at angle for — Moves the robot at a specific angle for a specific distance.

  • turn — Turns the robot left or right forever.

  • turn for — Turns the robot left or right for a specific number of degrees.

  • turn to heading — Turns the robot to face a specific heading.

  • 使用控制器移动 — 允许使用控制器驱动机器人。

  • 停止所有移动 — 停止机器人的所有移动。

设置 — 调整移动和转向速度。

位置 — 跟踪并修改机器人的位置。

  • position — Reports the robot’s current x or y coordinate.

  • set robot position — Changes the robot’s current x and y position to new values.

数值 — 检查移动状态。

  • move active? — Reports whether the robot is moving.

  • turn active? — Reports whether the robot is turning.

  • stopped? — Reports whether the robot is neither moving nor turning.

行动#

移动#

The move stack block moves the robot forward, reverse, left, or right forever using the current move velocity. The robot will continue to move until it is given another action, like moving in a different direction, turning, or stopping.

向前移动堆栈块#
move [forward v]

参数

描述

方向

The direction the robot moves:

  • forward
  • reverse
  • left
  • right

例子

开始时,向前#
when started
[Move forward]
move [forward v]

以角度移动#

The move at angle stack block moves the robot forever at a specific angle using the current move velocity. The angle is relative to the current position of the robot. The robot will continue to move until it is given another action, like moving in a different direction, turning, or stopping.

以 90 度移动堆叠块#
move at (90) degrees

参数

描述

角度

The angle, in degrees, that the robot moves. This can be an integer or decimal from -360 to 360.

示例

启动时,向右移动 90 度,等待 1 秒,然后向前移动 0 度,等待 1 秒,然后停止所有移动。#
when started
[Move right, then move forward and stop.]
move at (90) degrees
wait (1) seconds
move at (0) degrees
wait (1) seconds
stop all movement

启动时,以45.33度角向右斜移,等待1秒,然后停止所有移动。#
when started
[Move diagonally to the right and stop.]
move at (45.33) degrees
wait (1) seconds
stop all movement

移动#

The move for stack block moves the robot forward, reverse, left, or right for a specific distance using the current move velocity. The direction is relative to the current position of the robot. The project will wait until the robot is done moving before the next block in the stack runs.

向前移动 200 毫米堆块#
move [forward v] for (200) [mm v] ▶

参数

描述

方向

The direction the robot moves:

  • forward
  • reverse
  • left
  • right

距离

The distance the robot moves. This can be an integer or a decimal.

单元

The distance unit: mm (millimeters) or inches.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

例子

启动后,向前移动200毫米堆块#
when started
[Move forward for 200 mm]
move [forward v] for (200) [mm v] ▶

以一定角度移动#

The move at angle for stack block moves the robot at a specific angle for a specific distance using the current move velocity. The angle is relative to the current position of the robot. The project will wait until the robot is done moving before the next block in the stack runs.

以一定角度移动堆叠块#
move at (45) degrees for (200) [mm v] ▶

参数

描述

角度

The angle, in degrees, that the robot moves. This can be an integer or decimal from -360 to 360.

距离

The distance the robot moves. This can be an integer or a decimal.

单元

The distance unit: mm (millimeters) or inches.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

示例

启动时,以 90 度向右移动 50 毫米,然后以 0 度向前移动 100 毫米。#
when started
[Move right, then move forward.]
move at (90) degrees for (50) [mm v] ▶
move at (0) degrees for (100) [mm v] ▶

启动时,以 0 度向前行驶 100 毫米,同时所有 LED 闪烁红色。#
when started
[Drive forward and blink all LEDs red.]
move at (0) degrees for (100) [mm v] ◀ and don't wait
set [lightall v] LED color to [red v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds
set [lightall v] LED color to [red v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds

转动#

The turn stack block turns the robot left or right forever using the current turn velocity. The robot will continue to turn until it is given another action, like moving or stopping.

右转堆叠块#
turn [right v]

参数

描述

方向

The direction the robot turns: left or right.

例子

启动时,向左转,等待 1 秒,然后停止所有移动。#
when started
[Turn left, then stop.]
turn [left v]
wait (1) seconds
stop all movement

转向#

The turn for stack block turns the robot left or right for a specific number of degrees using the current turn velocity. The turn is relative to the current direction the robot is facing. The project will wait until the robot is done turning before the next block in the stack runs.

右转90度堆叠块#
turn [right v] for (90) degrees ▶

参数

描述

方向

The direction the robot turns: left or right.

角度

The number of degrees the robot turns. This can be an integer or a decimal.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

示例

启动时,向左转90度,然后向右转180度。#
when started
[Turn left, then turn around to the right.]
turn [left v] for (90) degrees ▶
turn [right v] for (180) degrees ▶

启动时,向右旋转 180 度,同时所有 LED 闪烁蓝色。#
when started
[Turn right and blink all LEDs blue.]
turn [right v] for (180) degrees ◀ and don't wait
set [lightall v] LED color to [blue v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds
set [lightall v] LED color to [blue v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds

转向航向#

A heading is the direction the robot is facing, measured in degrees. The turn to heading stack block turns the robot to face a specific heading using the current turn velocity. The robot will turn the shortest direction to reach the target heading.

The robot’s starting heading is 0 degrees.

The project will wait until the robot is done turning before the next block in the stack runs.

转向航向 90 度堆叠块#
turn to heading (270) degrees ▶

参数

描述

标题

The heading the robot should face, from -360 to 360 degrees.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

示例

when started
[Turn to face each cardinal direction.]
turn to heading (90) degrees ▶
wait (2) seconds
turn to heading (180) degrees ▶
wait (2) seconds
turn to heading (270) degrees ▶
wait (2) seconds
turn to heading (0) degrees ▶
wait (2) seconds

启动时,快速旋转 180 度,同时所有 LED 闪烁绿色。#
when started
[Turn around quickly and blink all LEDs green.]
turn to heading (180) degrees ◀ and don't wait
set [lightall v] LED color to [green v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds
set [lightall v] LED color to [green v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds

使用控制器移动#

The move with controller stack block lets you drive the robot using the One Stick Controller. This block only reads the controller input once, unless placed inside of a loop, such as a forever loop. If the loop stops and there are no other blocks telling the robot to move, the robot will keep going in the last direction you pushed the joystick.

move with controller

参数

描述

该块没有参数。

例子

when started
[Drive with the controller for five seconds.]
reset timer
while <(timer in seconds) [math_less_than v] [5]>
move with controller
结束
stop all movement

停止一切运动#

The stop all movement stack block stops all movement of the robot.

停止所有移动堆栈块#
stop all movement

参数

描述

该块没有参数。

例子

启动时,向右转,等待 1 秒,然后停止所有移动。#
when started
[Turn right, then stop.]
turn [right v]
wait (1) seconds
stop all movement

设置#

设置移动速度#

The set move velocity stack block tells the robot how fast to move. A higher percentage makes the robot move faster and a lower percentage makes the robot move slower.

Every project begins with the robot moving at 50% velocity by default.

A move velocity of 100% is equivalent to 200 millimeters per second (mmps).

将移动速度设置为 50% 堆叠格挡#
set move velocity to (50)%

参数

描述

速度

The velocity to move with from 0% to 100%.

例子

when started
[Move forward at the default velocity.]
set move velocity to (50)%
move at (0) degrees for (100) [mm v] ▶
wait (1) seconds
[Move slower.]
set move velocity to (20)%
move at (0) degrees for (100) [mm v] ▶
wait (1) seconds
[Move faster.]
set move velocity to (100)%
move at (0) degrees for (100) [mm v] ▶
wait (1) seconds

设置转弯速度#

The set turn velocity stack block tells the robot how fast to turn. A higher percentage makes the robot turn faster and a lower percentage makes the robot turn slower.

Every project begins with the robot turning at 50% velocity by default.

A turn velocity of 100% is equivalent to 150 degrees per second \(dps\).

将转弯速度设置为 50% 堆叠块#
set turn velocity to (50)%

参数

描述

速度

The velocity to turn with from 0% to 100%.

例子

when started
[Turn around at default velocity.]
set turn velocity to (50)%
turn [right v] for (180) degrees ▶
wait (1) seconds
[Turn around slower.]
set turn velocity to (20)%
turn [right v] for (180) degrees ▶
wait (1) seconds
[Turn around faster.]
set turn velocity to (100)%
turn [right v] for (180) degrees ▶
wait (1) seconds

位置#

位置#

The position reporter block reports the robot’s current x or y-coordinate.

At the beginning of a project, the robot’s x and y positions are set to 0. The position values change as the robot moves and can be set using the set robot position block.

x 位置(单位:毫米)报告块#
[x v] position in [mm v]

参数

描述

协调

The coordinate axis to report: x or y.

单元

The position unit: mm (millimeters) or inches.

例子

启动时,向前移动 200 毫米,重置位置,以 45 度对角移动 200 毫米,并在屏幕上打印更新的 X 和 Y 坐标。#
when started
move at (0) degrees for (200) [mm v] ▶
[Move forward and print the new coordinate and heading.]
set robot position x:[0] y:[0]
move at (45) degrees for (200) [mm v] ▶
print ([x v] position in [mm v]) on screen ▶
set cursor to next row on screen
print ([y v] position in [mm v]) on screen ▶

设置机器人位置#

The set robot position stack block changes the robot’s current x and y position to new values.

For example, if the robot has moved away from its starting point, setting x to 0 and y to 0 makes the robot’s current location the new 0, 0 position. Then the robot can track future positions based on that new value.

设置位置堆栈块#
set robot position x:[0] y:[0]

参数

描述

The x-position value to set for the robot, in mm.

The y-position value to set for the robot, in mm.

例子

when started
[Reset the robot's position after moving.]
move [forward v] for [60] [mm v] ▶
set robot position x:[0] y:[0]
print ([y v] position in [mm v]) on screen ▶

价值观#

move active#

The move active Boolean block reports whether the robot is moving. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is moving.

  • False — The robot is not moving.

This block works together with Motion blocks that have the and don’t wait parameter.

是移动活跃记者块#
<move active?>

参数

描述

该块没有参数。

例子

启动后,机器人向前移动 200 毫米,同时所有 LED 指示灯闪烁红色。机器人移动时,LED 指示灯每 0.5 秒亮起一次,停止移动后保持熄灭状态。#
when started
[Blink all of the LEDs when the robot is moving.]
move at (0) degrees for (200) [mm v] ◀ and don't wait
while <move active?>
set [lightall v] LED color to [red v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds
结束
set [lightall v] LED color to [off v]

turn active#

The turn active Boolean block reports whether the robot is turning. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is turning.

  • False — The robot is not turning.

This block works together with Motion blocks that have the and don’t wait parameter.

启动活跃的报告块#
<turn active?>

参数

描述

该块没有参数。

例子

启动后,右转180度,所有LED灯闪烁红色。转弯时,LED灯每0.5秒闪烁一次,转弯完成后熄灭。#
when started
[Blink all of the LEDs while the robot is turning.]
turn [right v] for (180) degrees ◀ and don't wait
while <turn active?>
set [lightall v] LED color to [red v]
wait (0.5) seconds
set [lightall v] LED color to [off v]
wait (0.5) seconds
结束
set [lightall v] LED color to [off v]

stopped#

The stopped Boolean block reports whether the robot is neither moving nor turning. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is not moving or turning.

  • False — The robot is moving or turning.

被阻止记者阻拦#
<stopped?>

参数

描述

该块没有参数。

例子

启动后,机器人会向前移动 200 毫米并进行灯光秀,然后右转 180 度并继续灯光秀。机器人移动或旋转时,LED 灯每 0.5 秒在绿色和紫色之间交替闪烁。机器人停止后,灯光秀结束,LED 灯熄灭。#
定义 light show
[Flash LEDs while the robot is moving or turning.]
repeat until <stopped?>
set [lightall v] LED color to [green v]
wait (0.5) seconds
set [lightall v] LED color to [purple v]
wait (0.5) seconds
结束


when started
[Blink all the LEDs while the robot is moving or turning.]
move at (0) degrees for (200) [mm v] ◀ and don't wait
light show
turn [right v] for (180) degrees ◀ and don't wait
light show