Pneumatics#
Introducción#
The pneumatics class is used to control a VEX Pneumatics device connected to a smart port.
It provides methods for activating a solenoid to extend or retract a pneumatic cylinder.
Class Constructors#
pneumatics(
int32_t index );
Class Destructor#
Destroys the pneumatics object and releases associated resources.
~pneumatics();
Parámetros#
Parámetro |
Type |
Descripción |
|---|---|---|
|
|
The Smart Port that the Pneumatic Solenoid is connected to, written as |
Example#
// Create the pneumatics instance on Port 1
pneumatics Pneumatics1 = pneumatics(PORT1);
Member Functions#
The pneumatics class includes the following member functions:
extend— Extend a cylinder.retract— Retract a cylinder.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 the solenoid is connected to the brain.
Before calling any pneumatics member functions, a pneumatics instance must be created, as shown below:
/* This constructor is required to use an
IQ (2nd gen) Pneumatics Solenoid. Replace the values
as needed. */
// Create the pneumatics instance on Port 1
pneumatics Pneumatics1 = pneumatics(PORT1);
extend#
Extends a pneumatic cylinder.
Available Functionsvoid extend(
cylinderType id );
Parámetro |
Type |
Descripción |
|---|---|---|
|
|
The cylinder to extend:
|
This function does not return a value.
Examples// Extend cylinder 1
Pneumatic1.extend(cylinder1);
// Extend all cylinders
Pneumatic1.extend(cylinderAll);
retract#
Retracts a pneumatic cylinder.
Available Functionsvoid retract(
cylinderType id );
Parámetro |
Type |
Descripción |
|---|---|---|
|
|
The cylinder to retract:
|
This function does not return a value.
Examples// Retract cylinder 2
Pneumatic1.retract(cylinder2);
// Retract all cylinders
Pneumatic1.retract(cylinderAll);
pump_on#
Turns the air pump on.
Available Functionsvoid pump_on();
This function does not have parameters.
Return ValuesThis function does not return a value.
Examples// Turn on the air pump
Pneumatic1.pump_on();
pump_off#
Turns the air pump off.
Available Functionsvoid pump_off();
This function does not have parameters.
Return ValuesThis function does not return a value.
Examples// Turn off the air pump
Pneumatic1.pump_off();
pump#
Controls the air pump state.
Available Functionsvoid pump(
bool state );
Parámetro |
Type |
Descripción |
|---|---|---|
|
|
The air pump state:
|
This function does not return a value.
Examples// Turn the pump on
Pneumatic1.pump(true);
// Turn the pump off
Pneumatic1.pump(false);
installed#
Returns whether the Pneumatic Solenoid is connected to the Brain.
Available Functionsbool installed();
This function does not have parameters.
Return ValuesReturns a Boolean indicating whether the solenoid is connected to the Brain or not.
trueif the solenoid is connected to the Brain.falseif the solenoid is not connected to the Brain.
// Check if the pneumatic solenoid is connected
if (Pneumatic1.installed()) {
// Pneumatic system is ready
Pneumatic1.pump_on();
}