机器人专用模块#

介绍#

The 123 Robot includes a Drivetrain, LED, speaker, Eye Sensor, and Gyro Sensor.

All standard VEXcode VR Blocks are available for use in the 123 Playspace Playground.

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

驱动系统——控制机器人的移动和转向。

  • 操作

    • drive - Moves the robot forward or reverse forever.

    • drive until - Moves the robot forward or reverse until it detects an object, crash, or line.

    • 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 from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.

    • stop driving - Stops the robot’s movement.

  • 设置

  • 价值观

    • drive is done - Reports whether the robot is finished moving.

    • drive heading - Reports the robot’s current heading from 0 to 359 degrees.

声音 - 通过 123 机器人的扬声器播放内置声音。

LED - 控制 123 机器人的中央 LED 灯。

  • glow - 设置 LED 灯的颜色。

动作 - 让 123 机器人执行预设行为。

  • act - 表演不同的情绪。

传感 - 读取 123 机器人传感器的数值。

  • 陀螺仪

    • detected crash — Reports whether the robot has detected a sudden impact.

  • 眼睛

    • eye found an object – Reports whether or not the Eye Sensor detects an object within range.

    • eye detects color – Reports whether the Eye Sensor detects a specified color.

    • eye hue – Reports the hue detected by the Eye Sensor.

    • eye bright object – Reports whether the detected object reflects a lot of light.

    • eye brightness – Reports the brightness detected by the Eye Sensor.

传动系统#

The 123 Robot has a two-wheel drivetrain that lets it drive and turn. The Drivetrain blocks control how the robot moves.

The drivetrain can measure distance in two ways: steps and mm (millimeters). One step is one square on a 123 Field.

行动#

驾驶#

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 for 2 seconds.]
驱动 [向前 v]
等待 (2) 秒
驱动停止

开车直到#

The drive until stack block moves the robot forward or reverse until the Eye Sensor detects an object, crash, or line.

驱动 [向前 v] 直到 [对象 v]

参数

描述

方向

The direction the robot moves: forward or reverse.

状况

The condition that stops the robot:

  • object — The Eye Sensor detects an object.
  • crash — The robot crashes into an object.
  • line — The Line Detector detects a line under the robot.

例子

当开始
[Reverse after a crash.]
驱动 [向前 v] 直到 [撞毁 v]
驱动 [反 v] (1) [步数 v]

驱动#

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] (1) [步数 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: steps or mm.

例子

当开始
[Drive back and forth.]
驱动 [向前 v] (3) [步数 v]
驱动 [反 v] (3) [步数 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 for 2 seconds.]
[右 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.

例子

当开始
[Turn left, then turn around to the 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 robot’s starting heading is 0 degrees.

归位至 (90) 度

参数

描述

标题

The direction the robot should face, in degrees. This can be an integer or a decimal from -359 to 359.

例子

当开始
[Turn to face the cardinal directions.]
归位至 (90) 度
等待 (2) 秒
归位至 (180) 度
等待 (2) 秒
归位至 (270) 度
等待 (2) 秒
归位至 (0) 度
等待 (2) 秒

停止驾驶#

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

驱动停止

参数

描述

此代码块没有参数。

例子

当开始
[Stop driving after 4 seconds.]
驱动 [向前 v]
等待 [4] 秒
驱动停止

设置#

设置驱动超时#

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.

例子

启动时,将行驶时间限制为 1 秒,然后旋转 90 度。#
当开始
[Turn right after driving for 1 second.]
设定驱动超时为 (1) 秒
驱动 [向前 v] (1000) [毫米 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. This can be an integer or a decimal from -359 to 359.

例子

当开始
[Face the new 0 degree heading.]
设定底盘归位至 (90) 度
归位至 (0) 度

价值观#

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 the following Drivetrain blocks: drive for, drive until, turn for, and turn to heading.

<驱动已结束?>

参数

描述

此代码块没有参数。

例子

当开始
[Glow blue after a crash.]
驱动 [向前 v] 直到 [撞毁 v]
永久循环
如果 <驱动已结束?> 那么
发光 [蓝色 v]
否则
发光 [绿色 v]

行驶方向#

A heading is the direction the robot is facing, measured in degrees. The drive heading reporter block reports the robot’s current heading from 0 to 359 degrees.

The robot’s starting heading is 0 degrees.

(底盘归位角度值)

参数

描述

此代码块没有参数。

例子

当开始
[Display the heading after turning.]
[右 v] 转 (450) 度
打印 (底盘归位角度值) ▶

声音#

播放声音#

播放声音 模块会播放机器人内置的声音之一。

播放声音 [鸣笛 v]

参数

描述

声音

下面显示的是其中一种内置声音。

声音名称

播放声音

喇叭

门铃

碰撞

随机的

播放以上 3 种声音中的随机一种。

例子

开始时,播放声音,表现得开心。#
当开始 :: hat events
[Play the doorbell sound.]
播放声音 [门铃 v]

引领#

辉光#

发光模块用于设置 LED 灯的颜色。

发光 [绿色 v]

参数

描述

颜色

LED灯颜色设置:

  • 绿色
  • 蓝色
  • 紫色
  • 关闭

例子

当开始 :: hat events
[Blink the LED light forever.]
永久循环
发光 [绿色 v]
等待 [0.5] 秒
发光 [灭 v]
等待 [0.5] 秒

行动#

行为#

act 模块用于让 123 机器人执行一系列行驶、转弯和发声行为,从而表现悲伤、快乐或疯狂。

表现 [难过 v]

参数

描述

情感

要表现的情绪。0

    悲伤 - 倒车,左转,再右转,播放“糟糕”的声音,然后向前行驶以
  • 悲伤。2
  • 开心 - 向右转360度并播放笑声以表现开心。4
  • - 向左转一圈,然后向右转一圈,同时播放“疯疯癫癫”的声音以
  • 疯狂

当开始 :: hat events
[Act out a happy behavior.]
表现 [开心 v]

传感#

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

陀螺仪#

The 123 Robot uses gyro sensing to detect sudden impacts, such as hitting a wall or object.

detected crash#

The detected crash Boolean block reports whether the robot has detected a sudden impact, such as hitting a wall or object hard enough to quickly change its motion.

  • True — A crash has been detected.

  • False — A crash has not been detected.

<检测到碰撞?>

参数

描述

此代码块没有参数。

例子

当开始
[Back up after a crash.]
驱动 [向前 v]
等到 <检测到碰撞?>
驱动 [反 v] (200) [毫米 v]

眼睛#

eye found an object#

The eye found an object Boolean block reports whether or not the Eye Sensor detects an object within range.

  • True — The Eye Sensor detects an object.

  • False — The Eye Sensor does not detect an object.

<辨色仪发现一个对象?>

参数

描述

此代码块没有参数。

例子

当开始
[Stop driving after detecting an object.]
设定辨色仪灯 [on v]
驱动 [向前 v]
等待 (0.1) 秒
等到 <辨色仪发现一个对象?>
驱动停止

eye detects color#

The eye detects color Boolean block reports whether the Eye Sensor detects a specified color, based on the detected hue value.

  • True – The Eye sensor detects the specified color.

  • False – The Eye sensor does not detect the specified color.

To check the exact hue value detected by the Eye Sensor, use the eye hue reporter block.

<辨色仪测得 [红色 v]?>

参数

描述

颜色

The color to detect:

  • red - A detected hue value between 340°-20°.
  • green - A detected hue value between 80°-145°.
  • blue - A detected hue value between 160°-250°.

例子

当开始
[Stop driving after detecting a green object.]
设定辨色仪灯 [on v]
驱动 [向前 v]
等待 (0.1) 秒
等到 <辨色仪测得 [绿色 v]?>
驱动停止

眼睛颜色#

The eye hue reporter block reports the hue detected by the Eye Sensor as a number from 0 to 359 degrees.

Hue is a way to describe color using numbers around a color wheel.

一个圆形色轮,显示完整的色调光谱,边缘标有度数,从顶部的 0° 到 360°,以 30° 为增量递增。

(辨色仪色度值)

参数

描述

此代码块没有参数。

例子

当开始
[Display if an object is pink.]
永久循环
清除所有行
如果 <[290] [math_less_than v] (辨色仪色度值) [math_less_than v] [350]> 那么
打印 [Pink!] ▶
等待 (0.1) 秒
否则
打印 [Not pink!] ▶
等待 (0.1) 秒

eye bright object#

The eye bright object Boolean block reports whether the object detected by the Eye Sensor is bright.

An object is considered bright when it reflects more than 70% brightness back to the Eye Sensor.

  • True — The detected object reflects more than 70% brightness.

  • False — The detected object reflects 70% brightness or less.

This can be used before checking for a color to make sure the object is reflecting enough light for the Eye Sensor to detect the color reliably.

<看到明亮对象?>

参数

描述

此代码块没有参数。

例子

当开始
[Display whether a detected object is bright.]
设定辨色仪灯功率为 (100)%
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
等待 (0.1) 秒
如果 <看到明亮对象?> 那么
打印 [Bright object!] ▶
否则
打印 [Object not bright.] ▶

眼睛亮度#

The eye brightness reporter block reports how much light is reflected back to the Eye Sensor, as a percentage from 0% to 100%.

A higher percentage means more light is reflected back to the Eye Sensor. A lower percentage means less light is reflected back.

(辨色仪亮度百分比)

参数

描述

此代码块没有参数。

例子

当开始
[Display whether a detected object is bright.]
设定辨色仪灯功率为 (100)%
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
等待 (0.1) 秒
如果 <(辨色仪亮度百分比) [math_less_than v] [70]> 那么
打印 [Object not bright.] ▶
否则
打印 [Bright object!] ▶