运动#

介绍#

电机模块可以控制电机正转或反转,将其移动到特定位置,并调整其速度、扭矩和超时设置。它们还可以报告编码器值以跟踪运动和位置。

Below is a list of all blocks:

Actions — Stop and spin motors.

  • spin — Spins the selected motor indefinitely.

  • spin for — Spins a motor for a specific distance.

  • spin to position — Spins a motor to a set position.

  • stop motor — Stops a specific motor from spinning.

Settings — Adjust motor settings.

Values — Check movement status.

  • motor is done? — Returns a Boolean indicating whether the motor is no longer spinning.

  • motor is spinning? — Returns a Boolean indicating whether the motor is currently spinning.

  • motor position — Returns the motor’s current rotational position.

  • motor velocity — Returns the motor’s current velocity.

  • motor current — Returns the current drawn by the motor.

行动#

旋转#

spin 块使用 当前电机速度 使选定的电机沿指定方向旋转。

[ArmMotor v] [向上 v] 转

参数

描述

发动机

在设备窗口中配置要旋转的电机。

方向

The direction to spin, configured in the Devices window. By default this is:

  • forward — Rotates the motor counterclockwise
  • reverse — Rotates the motor clockwise

例子

aria-description 写在这里#
当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor, then stop.]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

旋转#

The spin for block spins a selected motor for a specific amount of rotation using the current motor velocity.

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

参数

描述

发动机

在设备窗口中配置要旋转的电机。

方向

The direction to spin, configured in the Devices window. By default this is:

  • forward — Rotates the motor counterclockwise
  • reverse — Rotates the motor clockwise

距离

旋转量,为整数或小数。

单元

表示距离的计量单位:

扩大箭头

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

例子

aria-description 写在这里#
当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise and lower the ArmMotor.]
[ArmMotor v] [向上 v] 转 [180] [度 v] ▶
等待 [1] 秒
[ArmMotor v] [向下 v] 转 [180] [度 v] ▶

旋转至位置#

旋转到位置块使用当前 电机速度电机位置 将电机旋转到特定的绝对位置。

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

参数

描述

发动机

在设备窗口中配置要旋转的电机。

位置

电机旋转的目标位置。

单元

计量单位:

扩大箭头

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

例子

aria-description 写在这里#
当开始 :: 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] ▶

停止电机#

停止电机块立即停止选定的电机。

[ArmMotor v] 停止

参数

描述

发动机

要停止的电机,在设备窗口中配置。

例子

aria-description 写在这里#
当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor.]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

设置#

设置电机位置#

设置电机位置块为电机设置特定的位置值,从而更新编码器读数。

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

参数

描述

发动机

在设备窗口中配置要设置位置的电机。

位置

要设置的编码器位置值。

单元

计量单位:

例子

aria-description 写在这里#
当开始 :: 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] ▶

设定电机速度#

设置电机速度块将电机的默认旋转速度设置为项目中所有后续运动块的百分比。

set [ArmMotor v] velocity to [50] %

参数

描述

发动机

在设备窗口中配置要设置速度的电机。

速度

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

例子

aria-description 写在这里#
当开始 :: 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] ▶

设置电机停止#

设置电机停止块设置电机停止时的行为。

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

参数

描述

发动机

在设备窗口中配置要设置停止行为的电机。

停止行为

Sets how the motor stops:

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

例子

aria-description 写在这里#
当开始 :: 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] 停止

设置电机最大扭矩#

设置电机最大扭矩块设置电机可以施加多大的力。

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

参数

描述

发动机

在设备窗口中配置电机的最大扭矩。

扭矩

允许的最大扭矩,从 0% 到 100%。

例子

aria-description 写在这里#
当开始 :: 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] ▶

设置电机超时#

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

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

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

参数

描述

发动机

在设备窗口中配置要设置超时的电机。

时间

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

例子

aria-description 写在这里#
当开始 :: 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] ▶

价值观#

电机做好了吗?#

电机是否完成? 块返回一个布尔值,指示电机是否未旋转。

  • True — The motor is not spinning.

  • False — The motor is spinning.

Note: This block only detects movement from blocks that can expand to show the and don’t wait option.

<[ArmMotor v] 已结束?>

参数

描述

发动机

需要检查的电机,在设备窗口中配置。

例子

aria-description 写在这里#
当开始 :: 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]

电机在旋转吗?#

电机正在旋转? 块返回一个布尔值,指示电机是否正在旋转。

  • True — The motor is spinning.

  • False — The motor is not spinning.

Note: This block only detects movement from blocks that can expand to show the and don’t wait option.

<[ArmMotor v] 正在转?>

参数

描述

发动机

需要检查的电机,在设备窗口中配置。

例子

aria-description 写在这里#
当开始 :: 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]

电机位置#

电机位置块返回所选电机旋转的总距离。

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

参数

描述

发动机

需要检查的电机,在设备窗口中配置。

单元

计量单位:

例子

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

电机速度#

电机速度块返回电机的当前转速,范围从 -100% 到 100%。

([ArmMotor v] 转速为%)

参数

描述

发动机

需要检查的电机,在设备窗口中配置。

例子

aria-description 写在这里#
当开始 :: 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] 停止

电机电流#

电机电流块返回电机使用的电流,范围从 0% 到 100%。

([ArmMotor v] 电流%)

参数

描述

发动机

需要检查的电机,在设备窗口中配置。

例子

aria-description 写在这里#
当开始 :: 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] 停止