mil_pneumatic_actuator
- Pneumatic Actuator Board¶
Exceptions¶
- class mil_pneumatic_actuator.PnuematicActuatorDriverError(message)[source]¶
The base exception class for all exceptions/errors related to the Pneumatic Actuator Board.
Inherits from
Exception
.
- class mil_pneumatic_actuator.PnuematicActuatorDriverChecksumError(checksum_is, checksum_should_be)[source]¶
Exception representing an invalid checksum.
Inherits from
PnuematicActuatorDriverError
.
- class mil_pneumatic_actuator.PnuematicActuatorDriverResponseError(received, expected)[source]¶
Exception representing an invalid response.
Inherits from
PnuematicActuatorDriverError
.
- class mil_pneumatic_actuator.PnuematicActuatorTimeoutError[source]¶
Exception representing a serial timeout experienced by the board.
Inherits from
PnuematicActuatorDriverError
.
PneumaticActuatorDriver¶
- defclose_port
- defget_port
- defopen_port
- defping
- defset_port
- class mil_pneumatic_actuator.PnuematicActuatorDriver(port: str, baud: int = 9600, simulated: bool = False)[source]¶
Allows high level ROS code to interface with Daniel’s pneumatics board.
For the dropper and grabber systems, call service with
True
orFalse
to open or close. For the shooter system, sending aTrue
signal will pulse the valve.Further information on the board’s communication protocol can be found in the design documentation.
- Parameters
- close_port(port: int) int [source]¶
Closes a particular port.
- Parameters
port (int) – The port to close.
- Raises
PnuematicActuatorDriverResponseError – The expected response from the board was not received.
PnuematicActuatorDriverChecksumError – The checksum expected and the checksum received were not the same. The board may be malfunctioning or the communication with the board may be disrupted.
- Returns
- The response from the board, which is frequently a standard hexadecimal value
indicating that the board closed the valve at the desired port. This value is equal to
mil_pneumatic_actuator.Constants.CLOSE_RESPONSE
.
- Return type
- get_port(port: int) int [source]¶
Reads the data at a specific port.
- Parameters
port (int) – The port to read from.
- Raises
PnuematicActuatorDriverResponseError – The expected response from the board was not received.
PnuematicActuatorDriverChecksumError – The checksum expected and the checksum received were not the same. The board may be malfunctioning or the communication with the board may be disrupted.
- Returns
The response served by the board.
- Return type
- open_port(port: int) int [source]¶
Opens a particular port.
- Parameters
port (int) – The port to open.
- Raises
PnuematicActuatorDriverResponseError – The expected response from the board was not received.
PnuematicActuatorDriverChecksumError – The checksum expected and the checksum received were not the same. The board may be malfunctioning or the communication with the board may be disrupted.
- Returns
- The response from the board, which is frequently a standard hexadecimal value
indicating that the board opened the valve at the desired port. This value is equal to
mil_pneumatic_actuator.Constants.OPEN_RESPONSE
.
- Return type
- ping() int [source]¶
Sends a ping message to the board and returns the response.
- Raises
PnuematicActuatorDriverResponseError – The expected response from the board was not received.
PnuematicActuatorDriverChecksumError – The checksum expected and the checksum received were not the same. The board may be malfunctioning or the communication with the board may be disrupted.
- Returns
The response from the board.
- Return type
- set_port(port: int, do_open: bool) int [source]¶
Sets the data at a particular port to opened/closed. This does not depend on the internal state of the port when called, ie, if you request a port to be closed, and the port is already closed, then the response is sent anyways.
- Parameters
- Raises
PnuematicActuatorDriverResponseError – The expected response from the board was not received.
PnuematicActuatorDriverChecksumError – The checksum expected and the checksum received were not the same. The board may be malfunctioning or the communication with the board may be disrupted.
Pneumatic Board Constants¶
- class mil_pneumatic_actuator.Constants[source]¶
Constant codes and functions used in both the driver and the simulated board.
- OPEN_REQUEST_BASE¶
A constant representing a request to the board to open a valve. Currently set to
0x20
.- Type
- OPEN_RESPONSE¶
A constant representing a response from the board when the open request is sent. Currently set to
0x01
.- Type
- CLOSE_REQUEST_BASE¶
A constant representing a request to the board to close a valve. Currently set to
0x30
.- Type
- CLOSE_RESPONSE¶
A constant representing a response from the board when the close request is sent. Currently set to
0x00
.- Type
- READ_REQUEST_BASE¶
A constant representing a request to the board to read the value of a valve. Currently set to
0x40
.- Type
- PING_RESPONSE¶
A constant representing a response from the board when the ping request is sent. Currently set to
0x11
.- Type
- create_checksum(byte: int) int [source]¶
Creates a checksum given a piece of data. The checksum is calculated through the XOR operation.
- deserialize_packet(data: bytes) Tuple[int, int] [source]¶
Deserializes a piece of data (a bytes object) into a tuple of two numbers. The first number is the data carried by the packet, and the second is the checksum computed by the board.
- Returns
The serialized packet.
- Return type
- serialize_packet(byte: int) bytes [source]¶
Serializes a piece of data (an integer) into a bytes object.
- Returns
The serialized packet.
- Return type
SimulatedPnuematicActuatorBoard¶
- defwrite