气动元件#

介绍#

VEX V5 控制器可以通过 pneumatic 气动控制 CTE 气动系统。该类控制允许控制器控制气动泵并伸缩气缸。

注意:CTE 气动命令需要 CTE 模块。使用以下代码导入: using namespace cte;。

类构造函数#

pneumatic( 
  int32_t index );

类析构函数#

摧毁 pneumatic 物体并释放相关资源。

~pneumatic();

参数#

范围

类型

描述

index

int32_t

CTE气动电磁阀所连接的智能端口(例如,PORT1)。

笔记#

  • CTE气动指令只能与CTE气动部件配合使用。

  • 您必须手动导入 CTE 模块: using namespace cte;。

  • 该系统可以单独控制最多 4 个气缸,也可以同时控制所有气缸。

例子#

using namespace cte;

// Create a CTE Pneumatic Solenoid in Port 1
pneumatic ctePneumatic1 = pneumatic(PORT1);

// Turn on the pump and extend cylinder 1
ctePneumatic1.pump_on();
ctePneumatic1.extend(cylinder1);

成员功能#

pneumatic 类包含以下成员函数:

  • extend — 延伸圆柱体。

  • retract — 回缩圆柱体。

  • pump_on — 打开气动泵。

  • pump_off — 关闭气动泵。

  • pump — 打开或关闭气动泵。

  • installed — 返回螺线管是否连接到大脑。

在调用任何 pneumatic 成员函数之前,必须创建一个 pneumatic 实例,如下所示:

using namespace cte;

/* This constructor is required to use a
CTE Pneumatic Solenoid. Replace the values
as needed. */

// Create the pneumatic instance on Port 1
pneumatic ctePneumatics1 = pneumatic(PORT1);

extend#

伸出气缸。

Available Functions
void extend( 
  cylinderType id );

Parameters

范围

类型

描述

id

cylinderType

要伸出的气缸:

  • cylinder1
  • cylinder2
  • cylinder3
  • cylinder4
  • cylinderAll – 所有4个气缸

Return Values

此函数不返回值。

Examples
// Extend cylinder 1
ctePneumatic1.extend(cylinder1);

// Extend all cylinders
ctePneumatic1.extend(cylinderAll);

retract#

缩回气缸。

Available Functions
void retract( 
  cylinderType id );

Parameters

范围

类型

描述

id

cylinderType

要缩回的油缸:

  • cylinder1
  • cylinder2
  • cylinder3
  • cylinder4
  • cylinderAll – 全部4个油缸

Return Values

此函数不返回值。

Examples
// Retract cylinder 2
ctePneumatic1.retract(cylinder2);

// Retract all cylinders
ctePneumatic1.retract(cylinderAll);

pump_on#

启动气动泵。

Available Functions
void pump_on();

Parameters

此函数没有参数。

Return Values

此函数不返回值。

Examples
// Turn the pneumatic pump on
ctePneumatic1.pump_on();

pump_off#

关闭气动泵。

Available Functions
void pump_off();

Parameters

此函数没有参数。

Return Values

此函数不返回值。

Examples
// Turn the pneumatic pump off
ctePneumatic1.pump_off();

pump#

开启或关闭气动泵。

Available Functions
void pump( 
  bool state );

Parameters

范围

类型

描述

state

bool

要设置的状态: true 打开气动泵, false 关闭气动泵。

Return Values

此函数不返回值。

Examples
// Turn the pump on
ctePneumatic1.pump(true);

// Turn the pump off
ctePneumatic1.pump(false);

installed#

返回 CTE 气动螺线管是否与大脑连接。

Available Functions
bool installed();

Parameters

此函数没有参数。

Return Values

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

  • true 为螺线管与大脑连接时的值。

  • false ​​如果螺线管未连接到大脑。

Examples
// Check if the pneumatic solenoid is connected
if (ctePneumatic1.installed()) {
  // Pneumatic system is ready
  ctePneumatic1.pump_on();
}