气动#

介绍#

气动系统使用气泵和电磁阀来控制移动气缸的压缩空气。它可以通过代码打开或关闭气泵,并伸缩气缸。

以下是可用方法的列表:

方法——用气泵压缩或减压空气。

  • 延伸 – 延伸圆柱体。

  • retract – 缩回气缸。

  • pump_on – 打开气泵。

  • pump_off – 关闭气泵。

  • pump – 设置气泵的开启或关闭状态。

  • installed – 返回螺线管是否连接到Brain。

构造函数——手动初始化和配置气动装置。

  • 气动 – 创建气动对象。

对于下面的示例,配置的气动装置将被命名为“pneumatic_1”,并且在整个 API 文档的所有后续示例中引用气动类方法时将使用它。

方法#

延长#

extend 延伸圆柱体。

用法:
extend(cylinder)

参数

描述

圆柱

要伸出的气缸:

  • CYLINDER1
  • CYLINDER2
  • CYLINDERALL – 两个气缸
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)

收回#

retract 缩回气缸。

用法:
retract(cylinder)

参数

描述

圆柱

缩回的气缸:

  • CYLINDER1
  • CYLINDER2
  • CYLINDERALL – 两个气缸
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)

pump_on#

pump_on 打开气泵。

用法:
pump_on()

参数

描述

该方法没有参数。

# Extend and retract the cylinder
pneumatic_1.pump_on()
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)

pump_off#

pump_off 关闭气泵。

用法:
pump_off()

参数

描述

该方法没有参数。

# Extend and retract the cylinder
pneumatic_1.pump_on()
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
wait(0.5, SECONDS)
pneumatic_1.pump_off()

#

pump 打开或关闭气泵。

用法:
pump(state)

参数

描述

状态

空气压缩机状态:

  • True – 打开气泵。2
  • False` – 关闭气泵
# Extend and retract the cylinder
pneumatic_1.pump(True)
wait(1, SECONDS)
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)
wait(0.5, SECONDS)
pneumatic_1.pump(False)

已安装#

“installed”返回一个布尔值,指示螺线管是否连接到大脑。

  • “真”——螺线管与大脑相连。

  • “错误”——螺线管未连接到大脑。

用法:
installed()

参数

描述

该方法没有参数。

# Display if the pneumatics are installed
if pneumatic_1.installed():
    brain.screen.print("Installed!")

构造函数#

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

气动#

Pneumatic 构造函数在指定的智能端口中创建一个 Pneumatic 对象:

用法:
气动(端口)

范围

描述

端口

电磁阀连接到哪个智能端口,以“PORT”表示,后跟端口号,范围从 1 到 12。

# Construct a Pneumatic System "pneumatic_1" with the
# Pneumatic class
pneumatic_1 = Pneumatic(Ports.PORT1)

pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract()