传动系统#

介绍#

The VEX IQ (2nd gen) Drivetrain uses a built-in Gyro Sensor to support precise forward, reverse, and turning movements. These blocks allow the robot to move continuously or for set distances, rotate by degrees or to a heading, and respond to changes in its rotational orientation.

传动系统类别还包含配置模块,可用于设置驱动和转弯速度、定义停止行为、应用超时以避免执行停顿,以及手动更新机器人的航向或旋转值。这些功能在设计自主行为或实时调整时提供了灵活性。

Below is a list of all blocks:

Actions — Drive or turn the robot for a set distance, angle, or continuously.

  • drive — Drives the robot continuously.

  • drive for — Drives the robot for a set distance.

  • turn — Turns the robot continuously.

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

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

  • turn to rotation — Turns the robot to reach a specific cumulative rotation.

  • stop driving — Stops all robot movement.

Settings — Configure drivetrain speeds, stopping, timeouts, and rotation values.

Values — Return drivetrain motion status, heading, rotation, velocity, and current draw.

  • drive is done? — Returns a Boolean indicating whether the drivetrain is no longer moving.

  • drive is moving? — Returns a Boolean indicating whether the drivetrain is currently moving.

  • drive heading — Returns the drivetrain’s heading angle.

  • drive rotation — Returns how much the drivetrain has turned since the project started.

  • drive velocity — Returns the drivetrain’s current velocity.

  • drive current — Returns the current drawn by the drivetrain’s motors.

行动#

驾驶#

驱动 模块使用当前的 驱动速度 使传动系统向前或向后移动。该模块持续运行,直到另一个传动系统模块中断它或项目停止。

aria-description 放在这里#
驱动 [向前 v]

参数

描述

方向

机器人行驶方向:

  • 前进
  • 后退

例子

aria-description 放在这里#
当开始
[Drive forward, then stop.]
驱动 [向前 v]
等待 (2) 秒
驱动停止

开车去#

drive for 块使用当前 驱动速度 将传动系统向前或向后移动指定的距离。

aria-description 放在这里#
驱动 [向前 v] (200) [毫米 v] ▶

参数

描述

方向

机器人行驶方向:

  • 前进
  • 后退

距离

The distance the robot drives as an integer or decimal.

单元

The unit of measurement representing the distance:

  • mm — millimeters
  • inches

扩大箭头

默认情况下,这是一个等待块,因此传动系统会在运行下一个块之前完成移动。要使传动系统开始移动并立即运行下一个块,请展开该块并显示无需等待

例子

aria-description 放在这里#
当开始
[Drive backward 500 mm.]
驱动 [反 v] (500) [毫米 v] ▶

转动#

转弯 模块使用当前的 转弯速度 持续向左或向右转动传动系统。传动系统将持续转动,直到另一个传动系统模块运行或项目停止。

aria-description 放在这里#
[右 v] 转

参数

描述

方向

机器人转向方向:

  • 左转
  • 右转

例子

aria-description 放在这里#
当开始
[Turn right, then stop.]
[右 v] 转
等待 (2) 秒
驱动停止

转向#

turn for 块使用当前 转弯速度 将传动系统向左或向右转动特定的度数。

aria-description 放在这里#
[右 v] 转 (90) 度 ▶

参数

描述

方向

机器人转向方向:

  • 左转
  • 右转

角度

The number of degrees the robot turns as an integer or decimal.

扩大箭头

默认情况下,这是一个等待块,因此传动系统会在运行下一个块之前完成转动。要使传动系统开始转动并立即运行下一个块,请将块展开为并且不等待

例子

aria-description 放在这里#
当开始
[Turn left, then turn around to the right.]
[左 v] 转 (90) 度 ▶
[右 v] 转 (180) 度 ▶

转向航向#

转向航向 块使用当前 转弯速度 将传动系统转向特定航向。

aria-description 放在这里#
归位至 (90) 度 ▶

参数

描述

标题

The absolute heading the drivetrain will turn to from -360 to 360 degrees.

扩大箭头

默认情况下,这是一个等待块,因此传动系统会在运行下一个块之前完成转动。要使传动系统开始转动并立即运行下一个块,请将块展开为并且不等待

例子

aria-description 放在这里#
当开始
[Turn to face the cardinal directions.]
归位至 (90) 度 ▶
等待 (2) 秒
归位至 (180) 度 ▶
等待 (2) 秒
归位至 (270) 度 ▶
等待 (2) 秒
归位至 (0) 度 ▶
等待 (2) 秒

转向旋转#

转向旋转 块使用当前 转弯速度 将传动系统转向面向特定的旋转值。

aria-description 放在这里#
转向至 (90) 度 ▶

参数

描述

旋转

The cumulative rotation value the robot will turn to as an integer or decimal.

扩大箭头

默认情况下,这是一个等待块,因此传动系统会在运行下一个块之前完成转动。要使传动系统开始转动并立即运行下一个块,请将块展开为并且不等待

例子

aria-description 放在这里#
当开始
[Turn left, then spin in a circle clockwise and face right.]
转向至 (-90) 度 ▶
等待 (2) 秒
转向至 (450) 度 ▶

停止驾驶#

停止驾驶块立即停止传动系统的所有运动。

aria-description 放在这里#
驱动停止

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始
[Drive forward, then stop.]
驱动 [向前 v]
等待 [4] 秒
驱动停止

设置#

设置驱动速度#

设置驱动速度块将项目中所有后续移动块的默认移动速度设置为百分比。

aria-description 放在这里#
设定驱动速度为 (50)%

参数

描述

速度

将默认移动速度设置为 0% 至 100%。

例子

当开始
[Drive forward at the default velocity.]
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒
[Move slower.]
设定驱动速度为 (20)%
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒
[Move faster.]
设定驱动速度为 (100)%
驱动 [向前 v] (100) [毫米 v] ▶
等待 (1) 秒

设置转弯速度#

设置转弯速度块将项目中所有后续转弯块的默认速度设置为百分比。

aria-description 放在这里#
设定转向速度为 (50)%

参数

描述

速度

将默认转弯速度设置为 0% 至 100%。

例子

当开始
[Turn at default velocity.]
[右 v] 转 (100) 度 ▶
等待 (1) 秒
[Turn slower.]
设定转向速度为 (20)%
[右 v] 转 (100) 度 ▶
等待 (1) 秒
[Turn faster.]
设定转向速度为 (100)%
[右 v] 转 (100) 度 ▶
等待 (1) 秒

设置驱动器停止#

设置驱动停止块设置传动系统运动结束时传动系统的行为方式。

aria-description 放在这里#
设定驱动停止模式为 [刹车 v]

参数

描述

停止行为

Sets how the drivetrain stops:

  • brake — Stops immediately.
  • coast — Slows gradually to a stop.
  • hold — Stops and resists movement using motor feedback.

例子

启动时,将停止设置为滑行,向前行驶 2 秒,然后停止。#
当开始
[Drive forward and coast to a stop.]
设定驱动速度为 (100)%
设定驱动停止模式为 [滑行 v]
驱动 [向前 v]
等待 (2) 秒
驱动停止

设置驱动器超时#

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

Note: The drivetrain’s time limit is used to prevent Drivetrain blocks that do not reach their target position from stopping the execution of other blocks in the stack.

aria-description 放在这里#
设定驱动超时为 (1) 秒

参数

描述

时间

传动系统块在停止并移动到下一个块之前运行的最大秒数。

例子

启动时,将驱动时间限制为 1 秒,然后旋转 90 度。#
当开始
[Drive forward for 1 second, then turn.]
设定驱动超时为 (1) 秒
驱动 [向前 v] (25) [英寸 v] ▶
[右 v] 转 (90) 度 ▶

设置驾驶航向#

The set drive heading block sets the Inertial Sensor or Gyro Sensor’s current heading to a specified value.

aria-description 放在这里#
设定底盘归位至 (0) 度

参数

描述

标题

要分配的航向值(以度为单位)。

例子

aria-description 放在这里#
当开始
[Turn to the left.]
设定底盘归位至 (90) 度
归位至 (0) 度 ▶

设置驱动器旋转#

The set drive rotation block sets the Inertial Sensor or Gyro Sensor’s current cumulative rotation value.

aria-description 放在这里#
设定底盘转向至 (0) 度

参数

描述

旋转

要分配的累积旋转值(以度为单位)。

例子

aria-description 放在这里#
当开始
[Spin counterclockwise two times.]
设定底盘转向至 (720) 度
转向至 (0) 度 ▶

价值观#

开车完成了吗?#

**驱动完成?**块返回一个布尔值,指示传动系统是否没有移动。

  • True — The drivetrain is not moving.

  • False — The drivetrain is moving.

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

<驱动已结束?>

参数

描述

该块没有参数。

例子

当开始
[Start spinning when the drive is complete.]
驱动 [向前 v] (200) [毫米 v] ◀ 并且不等待
永久循环
如果 <驱动已结束?> 那么
[右 v] 转 (360) 度 ▶
退出循环
否则
在屏幕上设定光标至 (1) 行 (1) 列
在屏幕上打印 [Still Moving...]▶
等待 (0.1) 秒
清屏

驱动器正在移动吗?#

**驱动器正在移动?**块返回一个布尔值,指示传动系统是否正在移动。

  • True — The drivetrain is moving.

  • False — The drivetrain is not moving.

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

<驱动进行中?>

参数

描述

该块没有参数。

例子

当开始
[Print that the robot is moving while it is still driving.]
驱动 [向前 v] (200) [毫米 v] ◀ 并且不等待
当 <驱动进行中?>
在屏幕上设定光标至 (1) 行 (1) 列
在屏幕上打印 [Still Moving...]▶
等待 (0.1) 秒
清屏
结束
在屏幕上设定光标至 (1) 行 (1) 列
在屏幕上打印 [Done!]▶

行驶方向#

驱动航向块以十进制数返回传动系统的航向角,范围在 0 到 359.99 度之间。

(底盘归位角度值)

参数

描述

该块没有参数。

例子

当开始
[Display the heading after turning.]
[右 v] 转 (450) 度 ▶
在屏幕上打印 (底盘归位角度值)◀ 并设定光标为下一行

驱动旋转#

The drive rotation block returns how much the drivetrain has turned since the project started, in degrees as a decimal number: positive for clockwise, negative for counterclockwise.

(底盘转向角度值)

参数

描述

该块没有参数。

例子

当开始
[Display the rotation after turning.]
[右 v] 转 (450) 度 ▶
在屏幕上打印 (底盘转向角度值)◀ 并设定光标为下一行

驱动速度#

驱动速度块返回传动系统的当前速度,范围从 -100% 到 100% 或 -127 rpm 到 127 rpm。

(驱动速度 [% v])

参数

描述

单元

The unit of measurement:

  • % – from -100% to 100%
  • rpm – rotations per minute, from -127 to 127

例子

当开始
[Display the velocity as the robot is moving.]
驱动 [向前 v]
等待 (1) 秒
在屏幕上打印 (驱动速度 [% v])◀ 并设定光标为下一行
驱动停止

驱动电流#

驱动电流块返回电机或电机组所吸收的电流量,范围从 0.0 到 1.2 安培 (Amperes)。

(驱动电流 [amps v])

参数

描述

该块没有参数。

例子

当开始
[Display the current as the robot is moving.]
在屏幕上设定打印精度为 [0.01 v]
驱动 [向前 v]
等待 (1) 秒
在屏幕上打印 (驱动电流 [amps v])◀ 并设定光标为下一行
驱动停止