传动系统#

介绍#

VEX GO 传动系统使用内置惯性传感器来支持精确的前进、后退和转弯运动。这些模块使机器人能够连续移动或按设定距离移动、按角度旋转或按指定方向旋转,并响应其旋转方向的变化。

动力传动系统类别还包括配置块,可让您设置驱动和转动速度、定义停止行为、应用超时以避免执行停顿,以及手动更新机器人的航向或旋转值。

以下是所有可用块的列表:

动作——移动和转动机器人。

  • drive – 驱动机器人连续前进或后退。

  • drive for – 驱动机器人行驶一段设定的距离。

  • 驱动至 – 驱动至指定条件。

  • turn – 使机器人连续向左或向右转动。

  • turn for – 将机器人转动特定的度数。

  • 转向航向 – 让机器人转向特定的绝对航向。

  • 转向旋转 – 转动机器人以达到特定的累积旋转。

  • 停止驾驶 – 停止所有机器人运动。

设置——调整传动系统设置。

值——检查运动状态。

  • 驱动完成? – 返回一个布尔值,指示传动系统是否不再移动。

  • drive heading – 返回动力传动系统的航向角(0 到 359.99 度)。

  • 驱动旋转 – 返回自项目启动以来传动系统的转动量。

  • 驱动速度 – 返回传动系统的当前速度(以 % 为单位)。

行动#

驾驶#

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

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

参数

描述

方向

The direction in which the robot drives:

  • forward
  • reverse

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive forward then stop.]
驱动 [向前 v]
等待 (2) 秒
驱动停止

开车去#

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

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

参数

描述

方向

The direction in which the robot drives:

  • forward
  • reverse

距离

机器人行驶的距离,以整数或小数表示。

单元

The unit of measurement that represents the distance:

  • mm – Millimeters
  • inches

扩大箭头

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive back and forth.]
驱动 [向前 v] [100] [毫米 v] ▶
驱动 [反 v] [4] [英寸 v] ▶

开车直到#

驱动直到 块用于使用当前 驱动速度 无限期地移动传动系统,直到眼睛传感器检测到物体或机器人撞到物体或墙壁。

驱动 [向前 v] 直到 [撞毁 v] ▶

参数

描述

方向

The direction in which the robot drives:

  • forward
  • reverse

状况

The condition that stops the drivetrain:

  • crash – When the robot crashes into an object.
  • object – When the Eye Sensor detects an object (Eye Sensor must be installed).

扩大箭头

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn right after a crash.]
驱动 [向前 v] 直到 [撞毁 v] ▶
[右 v] 转 (90) 度 ▶

转动#

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

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

参数

描述

方向

The direction in which the robot turns:

  • left
  • right

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn right and left, then stop.]
[右 v] 转
等待 [2] 秒
[左 v] 转
等待 [2] 秒
驱动停止

转向#

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

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

参数

描述

方向

The direction in which the robot turns:

  • left
  • right

角度

机器人转动的度数,以整数或小数表示。

扩大箭头

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn right then left.]
[右 v] 转 (90) 度 ▶
[左 v] 转 (90) 度 ▶

转向航向#

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

aria-description 放在这里#
归位至 [90] 度 ▶

参数

描述

标题

传动系统转向的绝对方向,从 -360 度到 360 度。

扩大箭头

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn to face the cardinal directions.]
归位至 [90] 度 ▶
等待 [1] 秒
归位至 [180] 度 ▶
等待 [1] 秒
归位至 [270] 度 ▶
等待 [1] 秒
归位至 [0] 度 ▶

转向旋转#

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

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

参数

描述

旋转

机器人将旋转的累积旋转值,以整数或小数表示。

扩大箭头

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Spin around twice.]
转向至 (720) 度 ▶

停止驾驶#

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

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

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive forward then stop.]
驱动 [向前 v]
等待 (2) 秒
驱动停止

设置驱动速度#

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

aria-description 放在这里#
set drive velocity to [50] %

参数

描述

速度

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive at different velocities.]
驱动 [向前 v] [100] [毫米 v] ▶
等待 [1] 秒
[Drive slow.]
set drive velocity to [20] %
驱动 [向前 v] [100] [毫米 v] ▶
等待 [1] 秒
[Drive fast.]
set drive velocity to [100] %
驱动 [向前 v] [100] [毫米 v] ▶

设置转弯速度#

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

aria-description 放在这里#
set turn velocity to [50] %

参数

描述

速度

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn at different velocities.]
[右 v] 转 [180] 度 ▶
等待 [1] 秒
[Turn fast.]
set turn velocity to [100] %
[右 v] 转 [180] 度 ▶

设置驱动器停止#

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

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.

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive, then coast to a stop.]
set drive velocity to [100] %
设定驱动停止模式为 [滑行 v]
驱动 [向前 v]
等待 [2] 秒
驱动停止

设置驱动器超时#

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

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

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

参数

描述

时间

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Drive as far as possible for 1 second before turning right.]
设定驱动超时为 [1] 秒
驱动 [向前 v] [25] [英寸 v] ▶
[右 v] 转 [90] 度 ▶

设置驾驶航向#

设置驱动航向块将惯性传感器的当前航向设置为指定值。

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

参数

描述

标题

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Face the new 0 degree heading.]
设定底盘归位至 [90] 度
归位至 [0] 度 ▶

设置驱动器旋转#

设置驱动旋转块设置惯性传感器的当前累积旋转值。

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

参数

描述

旋转

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

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Spin counterclockwise two times.]
设定底盘转向至 [720] 度
转向至 [0] 度 ▶

价值观#

开车完成了吗?#

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

  • 正确 - 传动系统没有移动。

  • 错误 - 传动系统正在移动。

<驱动已结束?>

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Turn when the drivetrain is done moving forward.]
驱动 [向前 v] [100] [毫米 v] ◀ 并且不等待
等待 [0.25] 秒
永久循环
如果 <驱动已结束?> 那么
[右 v] 转 [180] 度 ▶
退出循环
否则
打印 [Still moving...] ▶
等待 [0.1] 秒
清除所有行

行驶方向#

驱动航向块返回传动系统的航向角,范围从 0 到 359.99 度。

(底盘归位角度值)

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Display the heading while turning.]
[右 v] 转 [450] 度 ◀ 并且不等待
永久循环
清除所有行
打印 (底盘归位角度值) ▶
等待 [0.1] 秒

驱动旋转#

驱动旋转块返回自项目启动以来传动系统的旋转角度(以度为单位):顺时针为正,逆时针为负。

(底盘转向角度值)

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Display the rotation while turning.]
[右 v] 转 [450] 度 ◀ 并且不等待
永久循环
清除所有行
打印 (底盘转向角度值) ▶
等待 [0.1] 秒

驱动速度#

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

(驱动速度为%)

参数

描述

该块没有参数。

例子

aria-description 放在这里#
当开始 :: hat events
[Build Used: Code Base 2.0]
[Display the velocity of the robot before and while moving.]
打印 [Start: ] ▶
打印 (驱动速度为%) ▶
设定光标至下一行
驱动 [向前 v]
等待 [0.5] 秒
打印 [Moving: ] ▶
打印 (驱动速度为%) ▶
驱动停止