机器人专用模块#

介绍#

GO 竞赛 - 火星数学探险 游乐场包含虚拟 GO 英雄机器人专属的积木,包括手臂电机控制和机器人专用传感积木。

所有标准 VEXcode VR 模块均可在 GO 竞赛 - 火星数学探险 游乐场中使用。

以下是所有可用的游乐场专用积木列表:

运动控制 - 控制机器人手臂电机的移动和跟踪。

感知——利用机器人的传感器。

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

运动#

行动#

旋转马达#

旋转电机模块使用当前电机速度使手臂电机沿指定方向旋转。

[ArmMotor v] [向上 v] 转

参数

描述

方向

电机旋转方向:

例子

当开始
[Raise the Arm Motor, then stop.]
[ArmMotor v] [向上 v] 转
等待 (1) 秒
[ArmMotor v] 停止

用于旋转马达#

spin motor for 模块使用 当前电机速度 使 Arm 电机旋转特定的圈数。

[ArmMotor v] [向上 v] 转 [90] [度 v] ▶

参数

描述

方向

电机旋转方向:

距离

旋转次数,以整数或小数表示。

单元

表示距离的计量单位:

展开箭头

默认情况下,这是一个等待块,因此电机将在运行下一个块之前完成运转。展开该块,添加“and don’t wait”即可将其更改为非等待块。

例子

当开始
[Raise the Arm Motor by 200 degrees.]
spin [ArmMotor v] [up v] for [200] [degrees v] ▶

旋转电机定位#

旋转电机定位 模块使用当前的 电机速度电机位置 将机械臂电机旋转到特定的绝对位置。

spin [ArmMotor v] to position [90] [degrees v] ▶

参数

描述

位置

电机旋转到的目标位置。

单元

计量单位:

展开箭头

默认情况下,这是一个等待块,因此电机将在运行下一个块之前完成运转。展开该块,添加“and don’t wait”即可将其更改为非等待块。

例子

当开始
[Move the Arm Motor to 180 degrees.]
spin [ArmMotor v] to position [180] [degrees v] ▶

停止电机#

停止电机 模块会立即停止机械臂电机。

[ArmMotor v] 停止

参数

描述

此代码块没有参数。

例子

当开始
[Raise the Arm Motor, then stop.]
[ArmMotor v] [向上 v] 转
等待 (1) 秒
[ArmMotor v] 停止

设置#

设定电机速度#

设置电机速度 模块将项目中所有后续运动模块的机械臂电机默认旋转速度设置为百分比。

set [ArmMotor v] velocity to [50] %

参数

描述

速度

设置默认移动速度,范围从 0% 到 100%。

例子

当开始
[Set the Arm Motor velocity to 100%.]
set [ArmMotor v] velocity to [100] %
spin [ArmMotor v] [up v] for [1] [turns v] ▶

设置电机超时#

设置电机超时模块用于设置电机模块到达目标位置的等待时间限制。如果机器人无法在设定的时间内完成移动,它将自动停止并继续执行下一个模块。

**注意:**电机的时间限制用于防止未到达目标位置的电机模块停止堆栈中其他模块的执行。

设定 [ArmMotor v] 超时为 [1] 秒

参数

描述

时间

电机模块在停止并移动到下一个模块之前将运行的最大秒数。

例子

当开始
[Limit Arm Motor movement to 1 second.]
设定 [ArmMotor v] 超时为 [1] 秒
spin [ArmMotor v] [up v] for [3] [turns v] ▶

位置#

电机位置#

电机位置模块返回机械臂电机旋转的总距离。

([ArmMotor v] 转位 [度 v] :: custom-motion)

参数

描述

单元

计量单位:

例子

当开始
[Print the Arm Motor position.]
打印 ([ArmMotor v] 转位 [度 v] :: custom-motion) ▶

设置电机位置#

设置电机位置 模块为机械臂电机设置一个特定的位置值,从而更新编码器读数。

设定 [ArmMotor v] 转位至 [0] [度 v]

参数

描述

位置

要设置的编码器位置值。

单元

计量单位:

例子

当开始
[Set the Arm Motor to 90 degrees, then return to 0 degrees.]
set [ArmMotor v] position to [90] [degrees v]
[ArmMotor v] 转至 [0] [度 v] ▶

价值观#

电机修好了吗?#

电机是否完成? 模块返回一个布尔值,指示机械臂电机是否停止旋转。

  • 没错——电机没有转动。

  • 错误 - 电机正在旋转。

注意:此模块仅检测可展开以显示无需等待选项的模块的移动。

<[ArmMotor v] 已结束?>

参数

描述

此代码块没有参数。

例子

当开始
[Check when the Arm Motor has finished moving.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ◀ 并且不等待
等待 (0.1) 秒
如果 <[ArmMotor v] 已结束?> 那么
print [Arm Motor is done.] ▶
结束

电机在转动吗?#

电机是否正在旋转? 模块返回一个布尔值,指示机械臂电机是否正在旋转。

  • 没错——电机正在转动。

  • 错误——电机没有转动。

注意:此模块仅检测可展开以显示无需等待选项的模块的移动。

<[ArmMotor v] 正在转?>

参数

描述

此代码块没有参数。

例子

当开始
[Check whether the Arm Motor is moving.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ◀ 并且不等待
等待 (0.1) 秒
如果 <[ArmMotor v] 正在转?> 那么
print [Arm Motor is spinning.] ▶
结束

电机速度#

电机速度模块返回手臂电机的当前旋转速度,范围从-100%到100%。

([ArmMotor v] velocity in [% v] :: custom-motion)

参数

描述

此代码块没有参数。

例子

当开始
[Print the Arm Motor velocity.]
print ([ArmMotor v] velocity in [% v] :: custom-motion) ▶

传感#

虚拟英雄机器人还可以访问标准的大脑和驱动系统传感模块。

眼睛#

眼睛发现了一个物体?#

“眼睛检测到物体?”模块返回一个布尔值,指示前置眼睛传感器是否在范围内检测到物体。

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

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

<[FrontEye v] found an object?>

参数

描述

此代码块没有参数。

例子

当开始
[Check whether the Front Eye Sensor detects an object.]
if <[FrontEye v] found an object?> then
print [Object detected!] ▶
否则
print [No object detected.] ▶
结束

眼睛能分辨颜色吗?#

眼睛检测到颜色? 模块返回一个布尔值,指示前置眼睛传感器是否检测到指定的颜色。

  • 正确 - 传感器检测到了指定的颜色。

  • 错误 - 传感器未检测到指定的颜色。

<[FrontEye v] 测得 [红色 v]?>

参数

描述

颜色

待检测的颜色:

  • 红色
  • 绿色
  • 蓝色

例子

当开始
[Check whether the Front Eye Sensor detects blue.]
if <[FrontEye v] detects [blue v]?> then
print [Blue object detected.] ▶
结束

眼睛亮度#

眼睛亮度模块返回前置眼睛传感器检测到的亮度,范围从 0% 到 100%。

([FrontEye v] 亮度百分比)

参数

描述

此代码块没有参数。

例子

当开始
[Print the brightness detected by the Front Eye Sensor.]
print ([FrontEye v] brightness in %) ▶

眼睛颜色#

眼睛色调模块返回前置眼睛传感器检测到的色调,数值范围为 0 到 359 度。

([FrontEye v] hue in degrees)

参数

描述

此代码块没有参数。

例子

当开始
[Print the hue detected by the Front Eye Sensor.]
print ([FrontEye v] hue in degrees) ▶

陀螺仪#

检测到崩溃?#

检测到崩溃? 模块返回一个布尔值,指示机器人是否发生崩溃。

  • 正确 - 检测到崩溃。

  • 错误 - 未检测到崩溃。

<检测到碰撞?>

参数

描述

此代码块没有参数。

例子

当开始
[Drive until the robot crashes, then stop.]
驱动 [向前 v]
等到 <检测到碰撞?>
驱动停止