运动#

介绍#

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

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

动作——停止并旋转马达。

  • spin – 无限旋转选定的电机。

  • spin for – 使电机旋转特定距离(以度或圈为单位)。

  • 旋转到位置 – 将电机旋转到设定位置。

  • 停止电机 – 停止特定电机旋转。

设置——调整电机设置。

  • 设置电机位置 – 设置电机的编码器值。

  • 设置电机速度 – 将电机速度设置为百分比。

  • 设置电机停止 – 设置停止行为(制动、滑行或保持)。

  • [设置电机最大扭矩](#set-motor-max-torque)——限制电机可施加的最大扭矩。

  • [设置电机超时](#set-motor-timeout)——限制当运动受阻时电机阻塞在放弃之前等待的时间。

值——检查运动状态。

行动#

旋转#

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

[ArmMotor v] [向上 v] 转

参数

描述

发动机

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

方向

旋转方向,在设备窗口中。默认值为:

  • 正向 - 电机逆时针旋转
  • 反向 - 电机顺时针旋转。4

例子

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

旋转#

spin for 块使用 当前电机速度 使选定的电机旋转特定的旋转量,以度或圈数为单位。

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

参数

描述

发动机

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

方向

旋转方向,在设备窗口中。默认值为:

  • 正向 - 电机逆时针旋转
  • 反向 - 电机顺时针旋转。4

距离

旋转量,为整数或小数。

单元

The unit of measurement representing the distance:

  • degrees
  • turns

扩大箭头

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

例子

aria-description goes here#
当开始 :: 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] ▶

参数

描述

发动机

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

位置

电机旋转的目标位置。

单元

The unit of measurement:

  • degrees
  • turns

扩大箭头

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

例子

aria-description goes here#
当开始 :: 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 goes here#
当开始 :: hat events
[Build Used: Competition Advanced 2.0]
[Raise the ArmMotor.]
[ArmMotor v] [向上 v] 转
等待 [1] 秒
[ArmMotor v] 停止

设置#

设置电机位置#

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

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

参数

描述

发动机

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

位置

要设置的编码器位置值。

单元

The unit of measurement:

  • degrees
  • turns

例子

aria-description goes here#
当开始 :: 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 goes here#
当开始 :: 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 goes here#
当开始 :: 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 goes here#
当开始 :: 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] ▶

设置电机超时#

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

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

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

参数

描述

发动机

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

时间

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

例子

aria-description goes here#
当开始 :: 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] ▶

价值观#

电机做好了吗?#

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

  • 真 - 电机没有旋转。

  • 错误 - 电机正在旋转。

<[ArmMotor v] 已结束?>

参数

描述

发动机

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

例子

aria-description goes here#
当开始 :: 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]

电机在旋转吗?#

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

  • 真 - 电机正在旋转。

  • 错误 - 电机未旋转。

<[ArmMotor v] 正在转?>

参数

描述

发动机

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

例子

aria-description goes here#
当开始 :: 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)

参数

描述

发动机

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

单元

The unit of measurement:

  • degrees
  • turns

例子

aria-description goes here#
当开始 :: 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 goes here#
当开始 :: 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 goes here#
当开始 :: 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] 停止