机器人专用模块#

介绍#

The VR Rover Robot includes a Drivetrain, Distance Sensor and actions unique to the Rover Rescue Playground.

All standard VEXcode VR blocks are available for use in the Rover Rescue Playground.

Below is a list of all available Robot-specific Blocks:

Drivetrain - Move and turn the VR Rover.

  • 操作

    • drive - Moves the VR Rover forward or reverse forever.

    • drive for - Moves the VR Rover forward or reverse for a specific distance.

    • turn - Turns the VR Rover left or right forever.

    • turn for - Turns the VR Rover left or right for a specific number of degrees.

    • 转向航向 - 将 VR 漫游车转向特定航向。

    • 前往目标 - 转动 VR 漫游车并将其驾驶到选定的目标上。

    • stop driving - Stops the VR Rover’s movement.

  • 设置

  • 价值观

    • drive is done - Reports whether the VR Rover is finished moving.

    • drive is moving - Reports whether the VR Rover is moving.

    • drive heading - Reports the VR Rover’s current heading from 0 to 359.99 degrees.

操作 - 与探测车的资源、敌人和内置人工智能系统进行互动。

  • 操作

  • 价值观

    • rover sees - 返回 VR 漫游车是否在其视野范围内看到物体。

    • rover detects - 返回 VR 漫游车在其探测半径内是否探测到矿物或敌人。

    • 存储中的矿物 - 返回 VR 漫游车携带的矿物数量。

    • 存储容量 - 返回 VR 漫游车的当前承载能力。

    • rover direction - 返回对象的方向(以度为单位)。

    • rover distance - 返回到对象的距离,单位为毫米或英寸。

    • 探测车位置 - 返回物体的 X 或 Y 坐标,单位为毫米或英寸。

    • under attack - Returns whether the VR Rover is currently under attack.

    • 敌人等级 - 返回检测到的最近敌人的等级。

    • 敌方辐射 - 返回检测到的最近敌人的辐射值。

    • 电池电量 - 返回 VR Rover 的当前电池电量(百分比)。

    • level - 返回 VR 漫游车的当前级别。

    • XP - 返回 VR 漫游车的当前经验值。

    • 受到攻击时 - 当 VR 漫游车受到攻击时运行附加模块。

    • 升级时 - 当 VR 漫游车升级时运行附加模块。

感知 - 使用探测车的距离传感器探测附近物体。

本页示例使用 Playground 的默认起始位置。

传动系统#

The drivetrain controls how the VR Rover drives and turns. The drivetrain can move forward or reverse, turn left or right, turn to headings, and report its heading.

行动#

驾驶#

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.

例子

当开始
[Drive forward, then stop.]
驱动 [向前 v]
等待 (2) 秒
驱动停止

驱动#

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.

例子

当开始
[Drive forward for 500 mm.]
驱动 [向前 v] (500) [毫米 v] ▶

转动#

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.

例子

当开始
[Turn right, then stop.]
[右 v] 转
等待 (2) 秒
驱动停止

转向#

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.

角度

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.

例子

当开始
[Turn left, then turn right.]
[左 v] 转 (90) 度 ▶
[右 v] 转 (180) 度 ▶

转向标题#

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) 度 ▶

参数

描述

标题

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.

例子

当开始
[Turn to face east.]
归位至 (90) 度 ▶

前往对象#

The go to object stack block turns and drives the VR Rover to the selected object.

go to [minerals v] ▶

参数

描述

目的

VR探测车将前往以下哪个目标:

  • 矿场
  • 敌方基地
  • 基地

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.

如果虚拟现实探测车探测到多个矿物或多个敌人,它将移动到距离较近的地点。

如果探测车在运行过程中,其视野范围内没有探测到矿物或敌人,则机器人不会行驶。基地始终可以被攻击。

例子

当开始
[Drive to the closest mineral.]
go to [minerals v] ▶

停止驾驶#

The stop driving stack block stops the robot’s movement.

驱动停止

参数

描述

此代码块没有参数。

例子

当开始
[Drive forward, then stop.]
驱动 [向前 v]
wait (4) seconds
驱动停止

设置#

设定驱动速度#

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: %

例子

当开始
[Move faster.]
设定驱动速度为 (100) [% v]
驱动 [向前 v] (100) [毫米 v] ▶

设定转弯速度#

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: %

例子

当开始
[Turn faster.]
设定转向速度为 (100) [% v]
[右 v] 转 (90) 度 ▶

设置驱动航向#

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) 度

参数

描述

标题

The heading value, in degrees, to set for the robot.

例子

当开始
[Set the heading, then turn to 0 degrees.]
设定底盘归位至 (90) 度
归位至 (0) 度 ▶

设置驱动超时#

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.

例子

当开始
[Drive for at most 1 second.]
设定驱动超时为 (1) 秒
驱动 [向前 v] (25) [英寸 v] ▶

价值观#

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.

<驱动已结束?>

参数

描述

此代码块没有参数。

例子

当开始
[Start turning 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.

<驱动进行中?>

参数

描述

此代码块没有参数。

例子

当开始
[Print while the rover is moving.]
驱动 [向前 v] (200) [毫米 v] ◀ 并且不等待
当 <驱动进行中?>
打印 [Still Moving...] ▶
等待 (0.1) 秒
清除所有行
结束
打印 [Done!] ▶

行驶方向#

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.

(底盘归位角度值)

参数

描述

此代码块没有参数。

例子

当开始
[Display the heading after turning.]
[右 v] 转 (90) 度 ▶
打印 (底盘归位角度值) ▶
设定光标至下一行

行动#

行动#

矿物质作用#

minerals [pick up v]

参数

描述

行动

如何处理矿物:

  • 拾取 - 将矿物放入虚拟现实漫游车
  • 上的矿物来恢复能量。6
  • 拾取矿物后,它们会被储存在虚拟现实漫游车中,直到被丢弃或使用为止。

    利用矿物可以补充虚拟现实探测车的部分能量。矿物只能在地面上才能使用。

    VR 漫游车通过使用矿物或将矿物丢弃在基地来获得经验值 (XP)。

    例子

    当开始
    [Drive to the closest mineral and pick it up.]
    go to [minerals v] ▶
    minerals [pick up v]
    

    吸收敌方辐射#

    吸收敌方辐射方块可以吸收漫游车救援游乐场中敌人的辐射。

    absorb radiation
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    [Drive to the closest enemy and absorb radiation.]
    go to [enemy v] ▶
    absorb radiation
    

    支持#

    待机模块使 VR Rover 进入待机模式,直到达到指定的电池阈值。

    standby until [50] % battery
    

    参数

    描述

    百分比

    使 VR Rover 退出待机模式的电池阈值,范围从 0 到 100。

    在待机状态下,VR Rover 的电池消耗速度较慢,但​​“剩余天数”计数器的增长速度更快。

    当电池电量达到设定的阈值时,VR Rover 将退出待机模式,恢复正常的电池使用和时间进程。

    如果选定的阈值等于或高于当前电池电量,VR Rover 将不会进入待机模式。

    例子

    当开始
    [Wait in standby until battery reaches 35%.]
    standby until [35] % battery
    go to [minerals v] ▶
    

    价值观#

    探测车看到#

    rover sees 模块返回一个布尔值,指示 VR 漫游车是否使用其内置 AI 技术看到所选对象。

    • 正确 - 所选物体位于 VR 漫游车 1000 毫米范围内,并且在其视野内。

    • 错误 - 所选对象距离超过 1000 毫米和/或超出视野范围。

    <sees [minerals v]?>
    

    参数

    描述

    目的

    要检查的对象:

    • 矿物
    • 敌人
    • 基地
    • 障碍物
    • 危险物

    VR Rover 的视野范围为 40 度,在小地图中显示为从 Rover 前端延伸出来的灰色半透明圆锥体。

    例子

    当开始
    永久循环
    if <sees [minerals v]?> then
    go to [minerals v] ▶
    结束
    结束
    

    探测车探测到#

    探测车探测 模块返回一个布尔值,指示 VR 探测车是否使用其内置 AI 技术探测矿物或敌人。

    • 正确 - 所选对象在探测车的探测半径内。

    • 错误 - 所选对象不在探测车的探测半径内。

    <detects [minerals v]?>
    

    参数

    描述

    目的

    要探测的目标:

    • 矿物
    • 敌人

    VR Rover 的探测半径为 800 毫米,在小地图上显示为 Rover 周围的黄色圆圈。

    例子

    当开始
    永久循环
    if <detects [minerals v]?> then
    go to [minerals v] ▶
    结束
    结束
    

    储存的矿物#

    存储中的矿物 模块返回 VR Rover 存储中当前的矿物数量。

    (minerals in storage)
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    print (minerals in storage) ▶
    设定光标至下一行
    

    存储容量#

    存储容量模块返回 VR 漫游车存储的承载容量。

    (storage capacity)
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    print (storage capacity) ▶
    设定光标至下一行
    

    探测车方向#

    漫游车方向模块以度为单位返回从 VR 漫游车到所选对象的方向。

    ([minerals v] direction in degrees)
    

    参数

    描述

    目的

    要报告哪个物体的方向:

    • 矿物
    • 敌方
    • 基地

    对于矿物和敌人,此模块仅在选定对象位于 1000 毫米以内且在探测车 40 度视野范围内时才会报告值。

    如果选择“基准”,即使基准不在视野范围内,也会报告方向。对于基准,此模块报告的值介于 -180 度到 180 度之间。

    例子

    当开始
    print ([minerals v] direction in degrees) ▶
    设定光标至下一行
    

    漫游车距离#

    漫游车距离模块返回虚拟现实漫游车到所选对象的距离。

    ([minerals v] distance in [mm v] :: custom-actions)
    

    参数

    描述

    目的

    要报告哪个物体的距离:

    • 矿物
    • 敌人
    • 障碍物
    • 危险物
    • 基地

    单元

    The unit used to report the distance: mm or inches

    对于矿物和敌人,此模块仅在选定对象位于 1000 毫米以内且在探测车 40 度视野范围内时才会报告值。

    如果选择了基准,即使基准不在视野范围内,也会报告距离。

    例子

    当开始
    print ([minerals v] distance in [mm v] :: custom-actions) ▶
    设定光标至下一行
    

    探测车位置#

    探测车位置模块使用探测车内置的人工智能技术返回所选对象的 X 或 Y 坐标。

    ([minerals v] location [X v] in [mm v])
    

    参数

    描述

    目的

    要报告哪个物体的位置:

    • 矿物
    • 敌人
    • 障碍物
    • 危险物
    • 基地

    要返回哪个坐标:

    • X
    • Y

    单元

    The unit used to report the coordinate: mm or inches

    对于矿物和敌人,此模块仅在选定对象位于 1000 毫米以内且在探测车 40 度视野范围内时才会报告值。

    如果选择了基地,即使基地不在视野范围内,也会报告其位置。

    例子

    当开始
    print ([base v] location [X v] in [mm v]) ▶
    设定光标至下一行
    print ([base v] location [Y v] in [mm v]) ▶
    设定光标至下一行
    

    under attack#

    The under attack block returns a Boolean indicating whether the VR Rover is currently under attack from an enemy.

    • 没错——VR探测车正遭受攻击。

    • 错误——VR探测车并未受到攻击。

    <under attack?>
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    永久循环
    if <under attack?> then
    drive [reverse v] for [500] [mm v] ▶
    结束
    结束
    

    敌人等级#

    敌人等级模块返回VR漫游车检测到的最近敌人的等级。

    (enemy level)
    

    参数

    描述

    此代码块没有参数。

    When no enemies are detected in the VR Rover’s detect radius, this block returns 0.

    例子

    当开始
    永久循环
    if <(enemy level) [math_equal v] [1]> then
    go to [enemy v] ▶
    否则
    drive [reverse v] for [500] [mm v] ▶
    结束
    结束
    

    敌方辐射#

    敌方辐射模块会返回VR探测到的最近敌人的辐射。

    (enemy radiation)
    

    参数

    描述

    此代码块没有参数。

    When no enemies are detected in the VR Rover’s detect radius, this block returns 0.

    例子

    当开始
    print (enemy radiation) ▶
    设定光标至下一行
    

    电池电量#

    电池电量模块以百分比形式返回 VR Rover 的当前电池电量。

    (battery level in % :: custom-actions)
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    print (battery level in % :: custom-actions) ▶
    设定光标至下一行
    

    等级#

    level 模块返回 VR 漫游车的当前级别。

    (level)
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    print (level) ▶
    设定光标至下一行
    

    XP#

    XP 模块返回 VR 漫游车当前拥有的经验值数量。

    (XP)
    

    参数

    描述

    此代码块没有参数。

    例子

    当开始
    print (XP) ▶
    设定光标至下一行
    

    遭受攻击时#

    受到攻击时模块会在每次 VR 漫游车受到敌人攻击时运行其附加堆栈。

    when under attack
    

    参数

    描述

    此代码块没有参数。

    例子

    when under attack
    absorb radiation
    

    升级时#

    当升级时模块会在 VR 漫游车每次从一层移动到下一层时运行其附加的堆栈。

    when level up
    

    参数

    描述

    此代码块没有参数。

    例子

    when level up
    print [The VR Rover has leveled up!] ▶
    设定光标至下一行
    

    传感#

    距离#

    Distance found an object#

    The Distance found an object block returns a Boolean indicating whether the Distance Sensor has detected an object within 2000 mm.

    • 正确 - 距离传感器已检测到物体。

    • 错误 - 距离传感器未检测到物体。

    <[distance v] found an object?>
    

    参数

    描述

    距离传感器

    Which Distance Sensor to use. In this Playground, the available sensor is distance.

    例子

    当开始
    [Turn until the Distance Sensor detects an object.]
    [右 v] 转
    wait until <[distance v] found an object?>
    驱动停止
    

    物距#

    物体距离模块返回距离传感器到最近物体的距离。

    ([distance v] in [mm v])
    

    参数

    描述

    距离传感器

    Which Distance Sensor to use. In this Playground, the available sensor is distance.

    单元

    The distance unit: mm or inches

    例子

    当开始
    [Wait until the Distance Sensor detects an object, then print the distance.]
    [右 v] 转
    wait until <[distance v] found an object?>
    驱动停止
    print ([distance v] in [mm v]) ▶