机器人专用模块#
介绍#
The Hero Bot, Dex, includes two motor options, an AI Vision Sensor, an Optical Sensor, and a Game Positioning System (GPS) Sensor.
All standard VEXcode VR Blocks are available for use in the V5RC 25-26 Push Back Playground.
Below is a list of all available Robot-specific Blocks:
Drivetrain – Move and turn the robot.
操作
drive — Moves the robot forward or reverse forever.
drive for — Moves the robot forward or reverse 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.
turn to rotation — Turns the robot to a specific rotation.
stop driving — Stops the robot’s movement.
设置
set drive velocity — Tells the robot how fast to drive.
set turn velocity — Tells the robot how fast to turn.
set drive heading — Changes the robot’s current heading to a new heading.
set drive rotation — Changes the robot’s current rotation to a new rotation.
set drive timeout — Sets how many seconds the robot will try to finish a movement.
价值观
drive is done — Reports whether the robot is finished moving.
drive is moving — Reports whether the robot is moving.
drive heading — Reports the robot’s current heading from 0 to 359.99 degrees.
drive rotation — Reports the robot’s current rotation.
drive velocity — Reports how fast the robot is driving.
运动控制——移动并跟踪机器人的电机。
操作
spin motor – Spins a motor forward or reverse forever.
spin motor for – Spins a motor for a specific distance in degrees or turns.
spin motor to position – Spins a motor to a specific position.
stop motor – Stops a motor from spinning.
设置
set motor velocity – Tells a motor how fast to spin.
set motor timeout – Sets how much time a motor will try to finish a movement.
set motor position – Changes the motor’s current position to a new value.
价值观
motor is done – Reports whether the motor is finished moving.
motor is spinning – Reports whether the motor is spinning.
motor position – Reports the motor’s current position.
motor velocity – Reports how fast the motor is spinning, as a percentage from -100% to 100%.
人工智能视觉——使用人工智能视觉传感器捕捉和分析物体。
感知——利用机器人的各种传感器。
光学的
Optical found an object – Reports whether the sensor is detecting an object within range.
Optical detects color – Reports whether the Optical Sensor detects a specified color.
Optical brightness – Reports the brightness detected by the Optical Sensor.
Optical hue – Reports the hue detected by the Optical Sensor.
when Optical – Runs the attached stack of blocks when the Optical Sensor detects or loses an object.
全球定位系统
本页示例使用 Playground 的默认起始位置。
Drivetrain#
The drivetrain controls how the VR Robot drives and turns. The drivetrain can move forward or reverse, turn left or right, turn to headings, and track its rotation.
行动#
drive#
The drive stack block moves the robot forward or reverse forever. The robot will continue to move until it is given another action, like turning or stopping.
驱动 [向前 v]
参数 |
描述 |
|---|---|
方向 |
The direction the robot moves: forward or reverse. |
例子
当开始 :: hat events
[Drive forward, then stop.]
驱动 [向前 v]
等待 (2) 秒
驱动停止
drive for#
The drive for stack block moves the robot forward or reverse for a specific distance. The project will wait until the robot is done moving before the next block in the stack runs.
驱动 [向前 v] (200) [毫米 v] ▶
参数 |
描述 |
|---|---|
方向 |
The direction the robot moves: forward or reverse. |
距离 |
The distance the robot drives. 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. |
例子
当开始 :: hat events
[Drive forward.]
驱动 [向前 v] (500) [毫米 v] ▶
turn#
The turn stack block turns the robot left or right forever. The robot will continue to turn until it is given another action, like driving or stopping.
[右 v] 转
参数 |
描述 |
|---|---|
方向 |
The direction the robot turns: left or right. |
例子
当开始 :: hat events
[Turn right, then stop.]
[右 v] 转
等待 (2) 秒
驱动停止
turn for#
The turn for stack block turns the robot left or right for a specific number of degrees. The turn is relative to the current position of the robot. The project will wait until the robot is done turning before the next block in the stack runs.
[右 v] 转 (90) 度 ▶
参数 |
描述 |
|---|---|
方向 |
The direction the robot turns: left or right. |
angle |
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. |
例子
当开始 :: hat events
[Turn left, then turn around to the right.]
[左 v] 转 (90) 度 ▶
[右 v] 转 (180) 度 ▶
turn to heading#
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 from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.
The starting heading is 0 degrees.
The project will wait until the robot is done turning before the next block in the stack runs.
归位至 (90) 度 ▶
参数 |
描述 |
|---|---|
heading |
The heading the robot should face, from -359 to 359 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. |
例子
当开始 :: hat events
[Turn to face the cardinal directions.]
归位至 (90) 度 ▶
等待 (2) 秒
归位至 (180) 度 ▶
等待 (2) 秒
归位至 (270) 度 ▶
等待 (2) 秒
归位至 (0) 度 ▶
等待 (2) 秒
turn to rotation#
The turn to rotation stack block turns the robot to a specific rotation.
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set drive rotation block.
Rotation values are absolute. This means the direction of the turn depends on the robot’s current rotation. Turning right increases the rotation, and turning left decreases the rotation.
For example, if the robot starts at 0 degrees and you turn to a rotation of 720 degrees, it will turn right twice. If you then turn to a rotation of 360 degrees, it will turn left once, because 360 is less than 720.
The project will wait until the robot is done turning before the next block in the stack runs.
转向至 (90) 度 ▶
参数 |
描述 |
|---|---|
rotation |
The rotation value, in degrees, that the robot will turn to. 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. |
例子
当开始 :: hat events
[Turn left, then spin in a circle clockwise and face right.]
转向至 (-90) 度 ▶
等待 (2) 秒
转向至 (450) 度 ▶
stop driving#
The stop driving stack block stops the robot’s movement.
驱动停止
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始 :: hat events
[Drive forward, then stop.]
驱动 [向前 v]
等待 [4] 秒
驱动停止
设置#
set drive velocity#
The set drive velocity stack block tells the robot how fast to drive. A higher percentage makes the robot drive faster and a lower percentage makes the robot drive slower.
Every project begins with the robot driving at 50% velocity by default.
Note: A higher velocity makes the robot drive faster, but it may be less precise. A lower velocity makes the robot drive slower, but it can be more precise.
设定驱动速度为 (50) [% v]
参数 |
描述 |
|---|---|
速度 |
The velocity to drive with from 0% to 100%. |
单元 |
The velocity unit: % |
例子
当开始 :: hat events
[Drive forward at the default velocity.]
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒
[Move slower.]
设定驱动速度为 (20) [% v]
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒
[Move faster.]
设定驱动速度为 (100) [% v]
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒
set turn velocity#
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.
Note: A higher velocity makes the robot turn faster, but it may be less precise. A lower velocity makes the robot turn slower, but it can be more precise.
设定转向速度为 (50) [% v]
参数 |
描述 |
|---|---|
速度 |
The velocity to turn with from 0% to 100%. |
单元 |
The velocity unit: % |
例子
当开始 :: hat events
[Turn at default velocity.]
[右 v] 转 (100) 度 ▶
等待 (1) 秒
[Turn slower.]
设定转向速度为 (20)%
[右 v] 转 (100) 度 ▶
等待 (1) 秒
[Turn faster.]
设定转向速度为 (100)%
[右 v] 转 (100) 度 ▶
等待 (1) 秒
set drive heading#
A heading is the direction the robot is facing, measured in degrees. The set drive heading stack block changes the robot’s current heading to a new heading value.
For example, if the robot has turned to face right, setting the heading to 0 degrees makes that right-facing position the new 0 degrees. Then the robot can turn to other positions based on that new heading.
设定底盘归位至 (0) 度
参数 |
描述 |
|---|---|
heading |
The heading value, in degrees, to set for the robot. |
例子
当开始 :: hat events
[Turn to the left.]
设定底盘归位至 (90) 度
归位至 (0) 度 ▶
set drive rotation#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The set drive rotation stack block changes the robot’s current rotation to a new value.
For example, if the robot has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the robot can turn to rotations based on that new value.
设定底盘转向至 (0) 度
参数 |
描述 |
|---|---|
rotation |
The rotation value, in degrees, to set for the robot. This can be an integer or a decimal. |
例子
当开始 :: hat events
[Spin counterclockwise two times.]
设定底盘转向至 (720) 度
转向至 (0) 度 ▶
set drive timeout#
The set drive timeout stack block sets how many seconds the robot will try to finish a movement. If the robot cannot finish in that time it will stop trying and move on to the next block in the stack. This keeps the robot from getting stuck on a movement.
设定驱动超时为 (1) 秒
参数 |
描述 |
|---|---|
时间 |
The number of seconds the robot can try to finish a movement. This can be a whole number or a decimal. |
例子
当开始 :: hat events
[Drive forward for 1 second, then turn.]
设定驱动超时为 (1) 秒
驱动 [向前 v] (25) [英寸 v] ▶
[右 v] 转 (90) 度 ▶
价值观#
drive is done#
The drive is done Boolean block reports whether the robot is finished moving. This can be used to control the timing of other behaviors based on the robot’s movement.
True — The robot is finished moving.
False — The robot is still moving.
This block works together with drivetrain blocks that have the and don’t wait parameter.
<驱动已结束?>
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始 :: hat events
[Start spinning when the drive is complete.]
驱动 [向前 v] (200) [毫米 v] ◀ 并且不等待
等到 <驱动已结束?>
[右 v] 转 (360) 度 ▶
drive is moving#
The drive is moving 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 drivetrain blocks that have the and don’t wait parameter.
<驱动进行中?>
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始 :: hat events
[Print that the robot is moving while it is still driving.]
驱动 [向前 v] (200) [毫米 v] ◀ 并且不等待
当 <驱动进行中?>
打印 [Still Moving...] ▶
等待 (0.1) 秒
清屏
结束
打印 [Done!] ▶
drive heading#
A heading is the direction the robot is facing, measured in degrees. The drive heading reporter block reports that heading from 0 to 359.99 degrees.
The robot’s starting heading is 0 degrees.
(底盘归位角度值)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始 :: hat events
[Display the heading after turning.]
[右 v] 转 (450) 度 ▶
在屏幕上打印 (底盘归位角度值)◀ 并设定光标为下一行
drive rotation#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The drive rotation reporter block reports the robot’s current rotation.
Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will report a rotation of 720 degrees.
(底盘转向角度值)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始 :: hat events
[Display the rotation after turning.]
[右 v] 转 (450) 度 ▶
在屏幕上打印 (底盘转向角度值)◀ 并设定光标为下一行
drive velocity#
The drive velocity reporter block reports how fast the robot is driving.
(驱动速度 [% v])
参数 |
描述 |
|---|---|
单元 |
The velocity unit: % |
例子
当开始 :: hat events
[Display the velocity after driving.]
驱动 [向前 v] (200) [毫米 v] ▶
在屏幕上打印 (驱动速度 [% v])◀ 并设定光标为下一行
运动#
Dex uses the intake motor to pull Blocks into the robot. The conveyor motor moves Blocks from the intake to the top of the robot so they can be pushed into a goal.
Each motor has its own direction options. The direction names describe how that motor moves on Dex.
行动#
旋转马达#
The spin motor stack block spins a motor in one of two directions forever. The motor will continue to spin until it is given another action, like spinning in a different direction or stopping.
spin [ConveyorMotor v] [up v]
参数 |
描述 |
|---|---|
发动机 |
The motor to spin: ConveyorMotor or IntakeMotor. |
方向 |
The direction the motor spins:
|
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [350] [mm v] ▶
用于旋转马达#
The spin motor for stack block spins a motor for a specific distance. The spin is relative to the current position of the motor. The project will wait until the motor is done spinning before the next block in the stack runs.
spin [ConveyorMotor v] [up v] for (90) [degrees v] ▶
参数 |
描述 |
|---|---|
发动机 |
The motor to spin: ConveyorMotor or IntakeMotor. |
方向 |
The direction the motor spins:
|
距离 |
The distance the motor spins. Degrees use integers. Turns can use integers or decimals. |
单元 |
The distance unit: degrees or turns. |
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. |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [350] [mm v] ▶
旋转电机定位#
The spin motor to position stack block spins a motor to a specific position.
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor position is set to 0 degrees. The motor position can also be set using the set motor position block.
Position values are absolute. This means the direction of the spin depends on the motor’s current position.
For example, if the motor starts at 0 degrees and spins to a position of 720 degrees, it will spin forward two turns. If it then spins to a position of 360 degrees, it will spin reverse one turn, because 360 is less than 720.
spin [ConveyorMotor v] to position (90) [degrees v] ▶
参数 |
描述 |
|---|---|
发动机 |
The motor to spin: ConveyorMotor or IntakeMotor. |
位置 |
The position value the motor will spin to. Degrees use integers. Turns can use integers or decimals. |
单元 |
The position unit: degrees or turns. |
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. |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] to position [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [350] [mm v] ▶
停止电机#
The stop motor stack block stops the selected motor.
stop [ConveyorMotor v]
参数 |
描述 |
|---|---|
发动机 |
The motor to stop: ConveyorMotor or IntakeMotor. |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [350] [mm v] ▶
stop [IntakeMotor v]
设置#
设定电机速度#
The set motor velocity stack block tells a motor how fast to spin. A higher percentage makes the motor spin faster and a lower percentage makes the motor spin slower.
Every project begins with each motor spinning at 50% velocity by default.
Note: A higher velocity makes the motor spin faster, but it may be less precise. A lower velocity makes the motor spin slower, but it can be more precise.
set [ConveyorMotor v] velocity to [50] [% v]
参数 |
描述 |
|---|---|
发动机 |
The motor to set the velocity of: ConveyorMotor or IntakeMotor. |
速度 |
The speed the motor will spin at. Percent uses whole numbers from 0% to 100%. |
单元 |
The velocity unit: %. |
例子
当开始
[Pick up a second Block.]
set [ConveyorMotor v] velocity to [100] [% v]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [400] [mm v] ▶
设置电机超时#
The set motor timeout stack block sets how much time a motor will try to finish a movement. If the motor cannot finish in that time, it will stop trying and move on to the next block in the stack. This keeps the motor from getting stuck on a movement.
set [ConveyorMotor v] timeout to [1] seconds
参数 |
描述 |
|---|---|
发动机 |
The motor to set the timeout of: ConveyorMotor or IntakeMotor. |
时间 |
The number of seconds the motor can try to finish a movement. This can be a whole number or decimal. |
例子
当开始
[Pick up a second Block.]
set [ConveyorMotor v] timeout to [0.5] seconds
spin [ConveyorMotor v] to position [1000] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [400] [mm v] ▶
位置#
电机位置#
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The motor position reporter block reports the motor’s current position.
At the beginning of a project, the motor position is set to 0 degrees. If the motor spins one full turn forward, the position will be 360 degrees or 1 turn. If the motor spins the other direction, the position will be negative.
([ConveyorMotor v] position in [degrees v])
参数 |
描述 |
|---|---|
发动机 |
The motor to report the position of: ConveyorMotor or IntakeMotor. |
单元 |
The unit to report the motor position in: degrees or turns. |
例子
当开始
[Pick up a second Block.]
while <([ConveyorMotor v] position in [degrees v]) [math_less_than v] [200]>
spin [ConveyorMotor v] [up v]
结束
stop [ConveyorMotor v]
spin [IntakeMotor v] [intake v]
drive [forward v] for [400] [mm v] ▶
设置电机位置#
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The set motor position stack block changes the motor’s current position to a new value.
For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.
set [ConveyorMotor v] position to (0) [degrees v]
参数 |
描述 |
|---|---|
发动机 |
The motor to set the position of: ConveyorMotor or IntakeMotor. |
位置 |
The position value the motor will spin to. Degrees use integers. Turns can use integers or decimals. |
单元 |
The position unit: degrees or turns. |
例子
当开始
[Pick up a second Block.]
set [ConveyorMotor v] position to [-200] [degrees v]
spin [ConveyorMotor v] to position [0] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [400] [mm v] ▶
价值观#
电机已完成#
The motor is done Boolean block reports whether the motor is finished moving. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is finished moving.
False — The motor is still moving.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ConveyorMotor v] is done?>
参数 |
描述 |
|---|---|
发动机 |
The motor to report whether it is finished moving: ConveyorMotor or IntakeMotor. |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] to position [300] [degrees v] ◀ and don't wait
驱动 [向前 v]
spin [IntakeMotor v] [intake v]
wait until <[ConveyorMotor v] is done?>
驱动停止
stop [IntakeMotor v]
motor is spinning#
The motor is spinning Boolean block reports whether the motor is spinning. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is spinning.
False — The motor is not spinning.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ConveyorMotor v] is spinning?>
参数 |
描述 |
|---|---|
发动机 |
The motor to report whether it is spinning: ConveyorMotor or IntakeMotor. |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] to position [300] [degrees v] ◀ and don't wait
等待 [0.1] 秒
while <[ConveyorMotor v] is spinning?>
驱动 [向前 v] [200] [毫米 v] ▶
spin [IntakeMotor v] [intake v]
电机速度#
The motor velocity reporter block reports how fast the motor is spinning, as a percentage from -100% to 100%.
([ConveyorMotor v] velocity in [% v] :: custom-motion)
参数 |
描述 |
|---|---|
发动机 |
The motor to report the velocity of: ConveyorMotor or IntakeMotor. |
单元 |
The unit to report the motor velocity in: %. |
例子
当开始
[Pick up a second Block.]
set [ConveyorMotor v] velocity to [100] [% v]
spin [ConveyorMotor v] to position [300] [degrees v] ◀ and don't wait
等待 [0.2] 秒
print ([ConveyorMotor v] velocity in [% v] :: custom-motion) ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [400] [mm v] ▶
人工智能视觉#
行动#
获取对象数据#
“获取对象数据”模块用于过滤来自 AI 视觉传感器帧的数据。AI 视觉传感器可以检测场地上的比赛元素。
数据集按宽度从大到小排序存储对象,索引从 0 开始。可以使用 AI Vision 对象属性 代码块访问每个对象的属性。如果没有检测到匹配的对象,则返回空数据集。
get [AI Classifications v] data from AI Vision
范围 |
描述 |
|---|---|
签名 |
筛选数据集仅包含具有给定签名的数据。唯一可用的签名是:
|
例子
当开始
[If an object is detected, pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
wait until <[Bumper v] pressed?>
驱动停止
退出循环
设置#
设置对象项#
设置对象项 块设置要使用数据集中的哪个项。
set [AIVision v] object item to [1]
参数 |
描述 |
|---|---|
物品 |
要使用的数据集中的项目编号。 |
例子
当开始
[Display what object is farthest away.]
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
set [AIVision v] object item to ([AIVision v] object count)
清除所有行
if <[AIVision v] object is [BlueBlock v]?> then
print [Blue Block farthest away.] ▶
否则
print [Red Block farthest away.] ▶
价值观#
object exists#
The object exists block returns a Boolean indicating whether any object is detected in the dataset.
正确——数据集中包含检测到的对象。
错误——该数据集不包含任何检测到的对象。
<[AIVision v] object exists?>
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[If an an object is detected, pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
wait until <[Bumper v] pressed?>
驱动停止
退出循环
人工智能分类是#
The AI Vision object is block returns a Boolean indicating whether a detected object matches a specific classification.
正确——数据集中的项就是特定的对象。
错误——数据集中的项不是特定对象。
<[AIVision v] object is [BlueBlock v]?>
范围 |
描述 |
|---|---|
目的 |
要将该物品与哪个对象进行比较:
|
例子
当开始
[Display what object is farthest away.]
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
set [AIVision v] object item to ([AIVision v] object count)
清除所有行
if <[AIVision v] object is [BlueBlock v]?> then
print [Blue Block farthest away.] ▶
否则
print [Red Block farthest away.] ▶
对象计数#
对象计数 模块返回数据集中检测到的对象数量,以整数形式表示。
([AIVision] object count)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[Display what object is farthest away.]
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
set [AIVision v] object item to ([AIVision v] object count)
清除所有行
if <[AIVision v] object is [BlueBlock v]?> then
print [Blue Block farthest away.] ▶
否则
print [Red Block farthest away.] ▶
对象属性#
使用 获取对象数据 块 后,每个对象都包含六个属性(如下所示)。
([AIVision v] object [width v])
某些属性值基于使用“获取对象数据”模块时,检测到的对象在 AI 视觉传感器视野中的位置。AI 视觉传感器的分辨率为 320 x 240 像素。
范围 |
描述 |
|---|---|
财产 |
要使用检测到的对象的哪个属性: |
宽度#
width 函数返回检测到的对象的宽度(以像素为单位),数值为 1 到 320 之间的整数。
([AIVision v] object [width v])
例子
当开始
[If an an object is detected, approach and pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [width v]) [math_greater_than v] [65]> then
驱动停止
退出循环
否则
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
高度#
height 返回检测到的对象的高度(以像素为单位),数值为 1 到 240 之间的整数。
([AIVision v] object [height v])
例子
当开始
[If an an object is detected, approach and pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [height v]) [math_greater_than v] [55]> then
驱动停止
退出循环
否则
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
centerX#
centerX 返回检测到的对象中心的 x 坐标(以像素为单位),数值为 0 到 320 之间的整数。
([AIVision v] object [centerX v])
例子
当开始
[Pick up a Block from the top left group.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
turn [left v] for [80] degrees ▶
驱动 [向前 v] [100] [毫米 v] ▶
set turn velocity to [20] [% v]
[左 v] 转
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <<[140] [math_less_than v] ([AIVision v] object [centerX v])> and <([AIVision v] object [centerX v]) [math_less_than v] [180]>> then
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
wait until <[Bumper v] pressed?>
驱动停止
中心Y#
centerY 返回检测到的对象中心的 y 坐标(以像素为单位),数值为 0 到 240 之间的整数。
([AIVision v] object [centerY v])
例子
当开始
[If an an object is detected, approach and pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [centerY v]) [math_greater_than v] [140]> then
驱动停止
退出循环
否则
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
originX#
originX 返回检测到的对象边界框左上角的 x 坐标(以像素为单位),数值为 0 到 320 之间的整数。
([AIVision v] object [originX v])
例子
当开始
[Pick up a Block from the top left group.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
turn [left v] for [80] degrees ▶
驱动 [向前 v] [100] [毫米 v] ▶
set turn velocity to [20] [% v]
[左 v] 转
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <<[100] [math_less_than v] ([AIVision v] object [originX v])> and <([AIVision v] object [originX v]) [math_less_than v] [140]>> then
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
wait until <[Bumper v] pressed?>
驱动停止
originY#
originY 返回检测到的对象边界框左上角的 y 坐标(以像素为单位),数值为 0 到 240 之间的整数。
([AIVision v] object [originY v])
例子
当开始
[If an an object is detected, approach and pick it up.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
永久循环
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <[120] [math_less_than v] ([AIVision v] object [originY v])> then
驱动停止
退出循环
否则
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
结束
结束
传感#
光学的#
Optical found an object#
The Optical found an object Boolean block reports whether or not the Optical Sensor detects an object within range.
True — The Optical Sensor detects an object.
False — The Optical Sensor does not detect an object.
<[Optical v] found an object?>
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[Move the preloaded Block to the top of the Conveyor.]
spin [ConveyorMotor v] [up v]
wait until <[Optical v] found an object?>
stop [ConveyorMotor v]
Optical detects color#
The Optical detects color Boolean block reports whether the Optical Sensor detects a specified color, based on the detected hue value.
True – The sensor detects the specified color.
False – The sensor does not detect the specified color.
<[Optical v] detects [red v]?>
参数 |
描述 |
|---|---|
颜色 |
Which color to look for:
|
例子
当开始
[Pick up and move a Blue Block to the top of the Conveyor.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [360] [mm v] ▶
spin [ConveyorMotor v] [up v]
wait until <[Optical v] detects [blue v]?>
stop [ConveyorMotor v]
光学亮度#
The Optical brightness reporter block reports how much light is reflected back to the Optical Sensor, as a percentage from 0% to 100%.
([Optical v] brightness in %)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[Move the preloaded Block to the top of the Conveyor.]
spin [ConveyorMotor v] [up v]
wait until <[0] [math_less_than v] ([Optical v] brightness in %)>
stop [ConveyorMotor v]
光学色调#
The Optical hue reporter block reports the hue detected by the Optical Sensor as a number from 0 to 359 degrees.
Hue is a way to describe color using numbers around a color wheel.

([Optical v] hue in degrees)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[Pick up and move a Blue Block to the top of the Conveyor.]
spin [ConveyorMotor v] [up v] for [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
drive [forward v] for [360] [mm v] ▶
spin [ConveyorMotor v] [up v]
wait until <[240] [math_equal v] ([Optical v] hue in degrees)>
stop [ConveyorMotor v]
光学#
The when Optical hat block runs the attached stack of blocks whenever the Optical Sensor detects or loses an object.
when [Optical v] [detects v] an object
参数 |
描述 |
|---|---|
state |
When the attached stack of blocks will run: detects runs when an undetected object is detected, while loses runs when a detected object is now no longer detected. |
全球定位系统#
GPS定位#
GPS 位置 模块使用 GPS(游戏定位系统™)传感器返回机器人转弯参考点相对于场地中心的偏移位置。
([GPS v] position [X v] in [mm v])
参数 |
描述 |
|---|---|
轴 |
要报告哪个坐标轴:
|
单位 |
The unit to represent the position: mm or inches |
例子
当开始
[Pick up a second Block.]
spin [ConveyorMotor v] to position [200] [degrees v] ▶
spin [IntakeMotor v] [intake v]
驱动 [向前 v]
wait until <[-450] [math_greater_than v] ([GPS v] position [Y v] in [mm v])>
驱动停止
GPS航向#
GPS航向模块根据GPS(游戏定位系统™)传感器从VEX GPS场码读取的0.00到359.99度的读数,返回机器人当前面向的航向。
([GPS v] heading in degrees)
参数 |
描述 |
|---|---|
此代码块没有参数。 |
例子
当开始
[Score the preloaded Block into a Center Goal.]
[左 v] 转
wait until <[40] [math_greater_than v] ([GPS v] heading in degrees)>
drive [forward v] for [1000] [mm v] ▶
[右 v] 转
wait until <([GPS v] heading in degrees) [math_greater_than v] [310]>
驱动 [反 v] [200] [毫米 v] ▶
spin [ConveyorMotor v] [up v]