运动#

介绍#

Motors control how parts of a robot move. Motors can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two motors can work together as a drivetrain to move and turn the whole robot.

Each motor is configured in the Devices window. Depending on the build, the names of the motors and directions can change. For example, the Competition Advanced 2.0 build has a motor named ArmMotor, with directions up and down. A custom robot may use different motor names or directions.

By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse in the Devices window, those directions will be switched.

A VEX GO Motor showing the forward direction indicated by a plus sign and an arrow indicating it is rotating left, or counterclockwise. A VEX GO Motor showing the reverse direction indicated by a minus sign and an arrow indicating it is rotating right, or clockwise.

There are many ways to code motors. Below is a list of all Motion blocks:

操作——停止和旋转电机。

设置 — 调整电机设置。

Values — Check motor status.

  • motor is done — Reports whether the motor is finished moving.

  • motor is spinning? — Reports whether the motor is spinning.

  • motor position — Reports the motor’s current position.

  • motor velocity — Reports how fast the motor is spinning, as a percentage from -100% to 100%.

  • motor current — Reports how much power the motor is using from the battery, as a percentage from 0% to 100%.

行动#

旋转马达#

The spin motor stack block spins a motor forward or reverse forever. The motor will continue to spin until it is given another action, like spinning in a different direction or stopping.

[ArmMotor v] [向上 v] 转

参数

描述

发动机

The motor to spin. Choose from the motors configured in the Devices window.

方向

The direction the motor spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor, then stop.]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

用于旋转马达#

The spin motor for stack block spins a motor for a specific distance. The spin is relative to the current position of the motor. The project will wait until the motor is done spinning before the next block in the stack runs.

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

参数

描述

发动机

The motor to spin. Choose from the motors configured in the Devices window.

方向

The direction the motor spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration.

距离

The distance the motor spins. Degrees use integers. Turns can use integers or decimals.

单元

The distance unit: degrees or turns.

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.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise and lower the ArmMotor.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[ArmMotor v] [向下 v] 转 [180] [度 v] ▶

旋转电机定位#

The spin motor to position stack block spins a motor to a specific position.

A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor position is set to 0 degrees. The motor position can also be set using the set motor position block.

Position values are absolute. This means the direction of the spin depends on the motor’s current position.

[ArmMotor v] 转至 (90) [度 v] ▶

参数

描述

发动机

The motor to spin. Choose from the motors configured in the Devices window.

位置

The position value the motor will spin to. Degrees use integers. Turns can use integers or decimals.

单元

The position unit: degrees or turns.

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.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Return ArmMotor to 0 degrees after raising.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[ArmMotor v] 转至 [0] [度 v] ▶

停止电机#

The stop motor stack block stops a motor from spinning.

[ArmMotor v] 停止

参数

描述

发动机

The motor to stop. Choose from the motors configured in the Devices window.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor.]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

设置#

设置电机位置#

A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The set motor position stack block changes the motor’s current position to a new value.

For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.

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

参数

描述

发动机

The motor to set the position for. Choose from the motors configured in the Devices window.

位置

The position value to set for the motor. Degrees use integers. Turns can use integers or decimals.

单元

The position unit: degrees or turns.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Return ArmMotor to 0 degrees after raising.]
设定 [ArmMotor v] 转位至 [0] [度 v]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[ArmMotor v] 转至 [0] [度 v] ▶

设定电机速度#

The set motor velocity stack block tells a motor how fast to spin. A higher percentage makes the motor spin faster and a lower percentage makes the motor spin slower.

Every project begins with each motor spinning at 50% velocity by default.

Note: A higher velocity makes the motor spin faster, but it may be less precise. A lower velocity makes the motor spin slower, but it can be more precise.

set [ArmMotor v] velocity to [50] %

参数

描述

发动机

The motor to set the velocity for. Choose from the motors configured in the Devices window.

速度

The velocity to spin with from 0% to 100%.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor at different velocities.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[Move slow.]
set [ArmMotor v] velocity to [20] %
[ArmMotor v] [向下 v] 转 [180] [度 v] ▶
等待 [1] 秒
[Move fast.]
set [ArmMotor v] velocity to [100] %
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶

设置电机停止#

The set motor stopping stack block sets how a motor will stop moving: by braking, coasting, or holding.

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

参数

描述

发动机

The motor to set the stopping behavior for. Choose from the motors configured in the Devices window.

停止行为

How the motor will stop:

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

For example, if a Competition Advanced 2.0 build is used and ArmMotor is set to hold, the motor will hold the arm at its current position until another arm movement happens. This means the motor will work against gravity to keep the arm in the air if the motor was stopped with the arm raised.

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

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor, then coast to a stop.]
set [ArmMotor v] velocity to [20] %
设定 [ArmMotor v] 停止模式为 [滑行 v]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

设置电机最大扭矩#

Torque is a turning force. It shows how hard a motor can push or pull when it spins.

The set motor max torque stack block sets the most torque a motor is allowed to use.

A higher percentage lets the motor push harder, like when lifting a heavy object. A lower percentage limits how hard the motor can push. This can help protect the robot if the motor gets stuck or reaches the end of how far it can move.

Every project begins with each motor’s torque at 50% by default.

set [ArmMotor v] max torque to (50)%

参数

描述

发动机

The motor to set the max torque for. Choose from the motors configured in the Devices window.

扭矩

The max torque the motor can use from 0% to 100%.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Move the ArmMotor at different torques.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[Move with less torque.]
设定 [ArmMotor v] 最大扭矩为 [20]%
[ArmMotor v] [向下 v] 转 [180] [度 v] ▶
等待 [1] 秒
[Move with maximum torque.]
设定 [ArmMotor v] 最大扭矩为 [100]%
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶

设置电机超时#

The set motor timeout stack block sets how many seconds a motor will try to finish a movement. If the motor cannot finish in that time, it will stop trying and move on to the next block in the stack. This keeps the motor from getting stuck on a movement.

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

参数

描述

发动机

The motor to set the timeout for. Choose from the motors configured in the Devices window.

时间

The number of seconds the motor can try to finish a movement. This can be a whole number or a decimal.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Move ArmMotor as far as possible for 1 second before resetting.]
设定 [ArmMotor v] 转位至 [0] [度 v]
设定 [ArmMotor v] 超时为 [1] 秒
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
[ArmMotor v] 转至 [0] [度 v] ▶

价值观#

电机做好了吗?#

The motor is done Boolean block reports whether the motor is finished moving. This can be used to control the timing of other behaviors based on the motor’s movement.

  • True — The motor is finished moving.

  • False — The motor is still moving.

This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.

<[ArmMotor v] 已结束?>

参数

描述

发动机

The motor to report whether it is finished moving. Choose from the motors configured in the Devices window.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Turn the Eye Sensor's light on while ArmMotor is moving.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ◀ 并且不等待
等待 [0.1] 秒
永久循环
如果 <[ArmMotor v] 已结束?> 那么
设定辨色仪灯 [灭 v]
否则
设定辨色仪灯 [on v]

电机在旋转吗?#

The motor is spinning? Boolean block reports whether the motor is spinning. This can be used to control the timing of other behaviors based on the motor’s movement.

  • True — The motor is spinning.

  • False — The motor is not spinning.

This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.

<[ArmMotor v] 正在转?>

参数

描述

发动机

The motor to report whether it is spinning. Choose from the motors configured in the Devices window.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Turn the Eye Sensor's light on while ArmMotor is moving.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ◀ 并且不等待
等待 [0.1] 秒
永久循环
如果 <[ArmMotor v] 正在转?> 那么
设定辨色仪灯 [on v]
否则
设定辨色仪灯 [灭 v]

电机位置#

A motor’s position is how far it has spun, measured in degrees or turns. The motor position reporter block reports the motor’s current position.

At the beginning of a project, the motor position is set to 0 degrees. If the motor spins one full turn forward, the position will be 360 degrees or 1 turn. If the motor spins the other direction, the position will be negative.

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

参数

描述

发动机

The motor to report the position of. Choose from the motors configured in the Devices window.

单元

The unit to report the motor position in: degrees or turns.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Display how far the ArmMotor moves after one second.]
设定 [ArmMotor v] 转位至 [0] [度 v]
打印 [Start: ] ▶
打印 ([ArmMotor v] 转位 [度 v] :: custom-motion) ▶
设定光标至下一行
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止
打印 [After: ] ▶
打印 ([ArmMotor v] 转位 [度 v] :: custom-motion) ▶

电机速度#

The motor velocity reporter block reports how fast the motor is spinning, as a percentage from -100% to 100%.

A positive value means the motor is spinning forward. A negative value means the motor is spinning in reverse.

([ArmMotor v] 转速为%)

参数

描述

发动机

The motor to report the velocity of. Choose from the motors configured in the Devices window.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Display the ArmMotor's velocity when it moves.]
打印 [Resting: ] ▶
打印 ([ArmMotor v] 转速为%) ▶
设定光标至下一行
[ArmMotor v] [向上 v] 转
等待 [1] 秒
打印 [Moving: ] ▶
打印 ([ArmMotor v] 转速为%) ▶
[ArmMotor v] 停止

电机电流#

The motor current reporter block reports how much power the motor is using from the battery, as a percentage from 0% to 100%.

A higher current value means the motor is using more power. This can happen when the motor is lifting something heavy, pushing against an object, or trying to move when it is stuck.

([ArmMotor v] 电流%)

参数

描述

发动机

The motor to report the current of. Choose from the motors configured in the Devices window.

例子

当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Display the motor's current when it moves.]
打印 [Resting: ] ▶
打印 ([ArmMotor v] 电流%) ▶
设定光标至下一行
[ArmMotor v] [向上 v] 转
等待 [1] 秒
打印 [Moving: ] ▶
打印 ([ArmMotor v] 电流%) ▶
[ArmMotor v] 停止