传动系统#

介绍#

The VEX IQ (2nd gen) robot uses a drivetrain to drive and turn. A drivetrain is made of motors and wheels that work together to move the robot.

A configured drivetrain can use a connected Gyro Sensor, the Brain’s built-in Inertial Sensor, or no sensor. When a sensor is used, the drivetrain uses it to help the robot move and turn precisely. At the start of each project, the drivetrain calibrates the sensor automatically. Keep the robot still for about 2 seconds during calibration, so the robot can move and turn correctly.

There are many ways to code the drivetrain. Below is a list of all Drivetrain blocks:

Actions — Move and turn the robot.

  • drive — Moves the robot forward or reverse forever.

  • 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.

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

  • stop driving — Stops the robot’s movement.

Settings — Adjust drivetrain settings.

Values — Check movement status.

行动#

驾驶#

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 backward 500 mm (millimeters).]
驱动 [反 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 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.

The project will wait until the robot is done turning before the next block in the stack runs.

归位至 (90) 度 ▶

参数

描述

标题

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

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 the cardinal directions.]
归位至 (90) 度 ▶
等待 (2) 秒
归位至 (180) 度 ▶
等待 (2) 秒
归位至 (270) 度 ▶
等待 (2) 秒
归位至 (0) 度 ▶
等待 (2) 秒

转向旋转#

The turn to rotation stack block turns the robot to a specific rotation.

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set drive rotation block.

Rotation values are absolute. This means the direction of the turn depends on the robot’s current rotation. Turning right increases the rotation, and turning left decreases the rotation.

For example, if the robot starts at 0 degrees and you turn to a rotation of 720 degrees, it will turn right twice. If you then turn to a rotation of 360 degrees, it will turn left once, because 360 is less than 720.

转向至 (90) 度 ▶

参数

描述

旋转

The rotation value, in degrees, that the robot will turn to. 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 spin in a circle clockwise and face right.]
转向至 (-90) 度 ▶
等待 (2) 秒
转向至 (450) 度 ▶

停止驾驶#

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

驱动停止

参数

描述

该块没有参数。

例子

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

设置#

设置驱动速度#

The set drive velocity stack block tells the robot how fast to drive. A higher velocity makes the robot drive faster and a lower velocity 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% when using %. rpm (revolutions per minute) uses values from 0 to 120.

单元

The unit of measurement: % or rpm (revolutions per minute).

例子

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

设置转弯速度#

The set turn velocity stack block tells the robot how fast to turn. A higher velocity makes the robot turn faster and a lower velocity 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% when using %. rpm (revolutions per minute) uses values from 0 to 120.

单元

The unit of measurement: % or rpm (revolutions per minute).

例子

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

设置驱动器停止#

The set drive stopping stack block sets how the robot will stop moving: by braking, coasting, or holding.

设定驱动停止模式为 [刹车 v]

参数

描述

停止行为

How the robot will stop:

  • brake — Stops immediately.
  • coast — Slows to a stop.
  • hold — Stops immediately and holds the wheels’ position.

If this block is not used, the robot will use brake when stopping.

例子

当开始
[Drive forward and coast to a stop.]
设定驱动速度为 (100) [% v]
设定驱动停止模式为 [滑行 v]
驱动 [向前 v]
等待 (2) 秒
驱动停止

设置驱动器超时#

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 an integer or a decimal.

例子

当开始
[Drive forward for 1 second, then turn.]
设定驱动超时为 (1) 秒
驱动 [向前 v] (25) [英寸 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 0 to 359.

例子

当开始
[Turn to the left.]
设定底盘归位至 (90) 度
归位至 (0) 度 ▶

设置驱动器旋转#

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The set drive rotation stack block changes the robot’s current rotation to a new value.

For example, if the robot has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the robot can turn to rotations based on that new value.

设定底盘转向至 (0) 度

参数

描述

旋转

The rotation value, in degrees, to set for the robot. This can be an integer or a decimal.

例子

当开始
[Spin counterclockwise two times.]
设定底盘转向至 (720) 度
转向至 (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 that have the and don’t wait parameter: drive for, turn for, turn to heading, and turn to rotation.

<驱动已结束?>

参数

描述

该块没有参数。

例子

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

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 the following Drivetrain blocks that have the and don’t wait parameter: drive for, turn for, turn to heading, and turn to rotation.

<驱动进行中?>

参数

描述

该块没有参数。

例子

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

行驶方向#

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) 度 ▶
在屏幕上打印 (底盘归位角度值)◀ 并设定光标为下一行

驱动旋转#

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The drive rotation reporter block reports the robot’s current rotation.

Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will report a rotation of 720 degrees.

(底盘转向角度值)

参数

描述

该块没有参数。

例子

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

驱动速度#

The drive velocity reporter block reports how fast the robot is driving.

It can report velocity as a percentage from -100% to 100%, or in rpm (revolutions per minute) from -127 to 127. A positive value means the robot is driving forward. A negative value means the robot is driving in reverse.

(驱动速度 [% v])

参数

描述

单元

The unit to report drive velocity in: % (from -100% to 100%) or rpm (revolutions per minute, from -127 to 127).

例子

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

驱动电流#

The drive current reporter block reports how much electrical current the drivetrain is using, measured in amps (amperes) from 0.0 to 1.2 A. Current is the amount of electricity flowing through the drivetrain.

A higher current value means the drivetrain is using more electrical current. This can happen when the robot is pushing against an object or trying to move when it is stuck.

This can be used to check if the drivetrain is struggling during a movement. If current stays high, the drivetrain may get warmer or use power less efficiently.

(驱动电流 [amps v])

参数

描述

该块没有参数。

例子

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