磁铁#

介绍#

VEX GO 电磁铁可让您的机器人通过拾取和释放磁性物体来与它们进行交互。

在以下示例中,配置的电磁铁将被命名为 magnet在本 API 文档的所有后续示例中,当引用 Magnet 类方法时,都将使用此名称。

以下是所有方法的列表:

操作——启用或禁用电磁铁。

  • energize — 设置电磁铁的状态,使其能够拾取或放下物体。

行动#

energize#

energize 设置电磁铁的状态,使其能够拾取或放下物体。

Usage:
magnet.energize(action)

参数

描述

action

The state of the electromagnet to set:

  • BOOST — Enables the magnet to pick up objects.
  • DROP — Disables picking up objects and drops any held objects.

# Build Used: Super Code Base 2.0
def main():
    # Drop an attached Disk
    drivetrain.drive_for(FORWARD, 200, MM)
    magnet.energize(DROP)
    drivetrain.drive_for(REVERSE, 200, MM)

# Start threads — Do not delete
start_thread(main)