磁铁#

介绍#

V5 磁铁仅与 V5 工作单元一起使用。

以下是可用方法列表:

操作——与磁铁互动。

  • pickup – Activates the Magnet to pick up an object.

  • drop – Deactivates the Magnet to drop an object.

  • set_power – Sets the power level of the Magnet used to pickup and drop.

Getters – 返回来自 Magnet 的数据。

  • temperature – Returns the temperature of the Magnet.

  • installed – Checks if the Magnet is connected.

  • timestamp – Returns the timestamp of the last received status packet from the Magnet.

构造函数 – 手动初始化和配置 Magnet。

行动#

pickup#

pickup(duration, units, power) activates the Magnet to pick up an object.

Usage: magnet.pickup(duration, units, power)

参数

描述

duration

可选。磁铁激活的持续时间,以整数或浮点数表示。

units

Optional. Units for the duration:

  • MSEC (Default)
  • SECONDS

power

可选。要设置的功率级别(0-100)。

# Set the Magnet to pickup.
magnet.pickup()

# Set the Magnet to pickup for 250 milliseconds at
# 90% power.
magnet.pickup(250, MSEC, 90)

drop#

drop() deactivates the Magnet to drop an object.

Usage: magnet.drop(duration, units, power)

参数

描述

duration

(可选)磁铁停用的持续时间,数值为整数或浮点数。

units

Optional. Units for the duration:

  • MSEC (Default)
  • SECONDS

power

可选。要设置的功率级别(0-100)。

# Set the Magnet to drop.
magnet.drop()

# Set the Magnet to drop for 250 milliseconds at
# 90% power.
magnet.drop(250, MSEC, 90)

set_power#

set_power(value) sets the power level of the Magnet used to pickup and drop.

Usage: magnet.set_power(value)

参数

描述

value

要设置的功率级别(0 - 100)。

# Set the default power to 80%. 
magnet.set_power(80)

获取器#

temperature#

temperature() returns the temperature of the Magnet as a float.

Usage: magnet.temperature(units)

参数

描述

units

Optional. Units for the temperature :

  • CELSIUS (Default)
  • FAHRENHEIT

installed#

installed() returns a Boolean if the Magnet is connected.

  • True - The Magnet is connected to the Brain.

  • False - The Magnet is not connected to the Brain.

Usage: magnet.installed()

参数

描述

此方法没有参数。

timestamp#

timestamp() returns an integer as the timestamp of the last received status packet from the Magnet.

Usage: magnet.timestamp()

参数

描述

此方法没有参数。

构造函数#

构造函数用于手动创建 Magnet 对象,这是在 VEXcode 之外配置 Magnet 所必需的。

Electromagnet#

电磁铁产生磁体。

用法: magnet_1 = Electromagnet(port)

范围

描述

port

Which Smart Port that the magnet is connected to as Ports.PORT followed by the port number, ranging from 1 to 12.

# Create a Magnet in Port 1.
magnet_1 = Electromagnet(Ports.PORT1)