气动#

介绍#

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

For the examples below, the configured Pneumatic Solenoid will be named pneumatic_1 and will be used in all subsequent examples throughout this API documentation when referring to Pneumatic class methods.

以下是可用方法的列表:

动作——用气泵压缩或减压空气。

Mutators——用气泵压缩或减压空气。

  • pump_on – Turn on the air pump.

  • pump_off – Turn off the air pump.

  • pump – Set the on or off state of the air pump.

吸气剂 – 检查螺线管是否连接。

  • installed – Returns whether or not a solenoid is connected to the Brain.

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

行动#

extend#

extend extends a cylinder.

Usage:
pneumatic_1.extend(cylinder)

参数

描述

cylinder

The cylinder to extend:

  • CYLINDER1
  • CYLINDER2
  • CYLINDERALL – Both cylinders
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)

retract#

retract retracts a cylinder.

Usage:
pneumatic_1.retract(cylinder)

参数

描述

cylinder

The cylinder to retract:

  • CYLINDER1
  • CYLINDER2
  • CYLINDERALL – Both cylinders
# Extend and retract the cylinder
pneumatic_1.extend(CYLINDER1)
wait(2, SECONDS)
pneumatic_1.retract(CYLINDER1)

修改器#

pump_on#

pump_on turns the air pump on.

Usage:
pneumatic_1.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 turns the air pump off.

Usage:
pneumatic_1.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 turns the air pump on or off.

Usage:
pneumatic_1.pump(state)

参数

描述

state

The air compressor state:

  • True – Turn the air pump on.
  • False – Turn the air pump off.
# 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 returns a Boolean indicating whether the solenoid is connected to the Brain.

  • True - The solenoid is connected to the Brain.

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

Usage:
pneumatic_1.installed()

参数

描述

该方法没有参数。

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

构造函数#

Constructors are used to manually create Pneumatic objects, which are necessary for configuring Pneumatics outside of VEXcode.

Pneumatics#

The Pneumatic constructor creates a Pneumatic object in the specified Smart Port:

Usage:
pneumatic_1 = Pneumatic(port)

范围

描述

port

Which Smart Port that the solenoid is connected to as Ports.PORT followed by the port number, ranging from 1 to 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()