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

Methods
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 or False to open or close. For the shooter system, sending a True signal will pulse the valve.

Further information on the board’s communication protocol can be found in the design documentation.

Parameters
  • port (str) – The nname of the board to establish a serial connection to.

  • baud (int) – The baud rate to establish the serial connection at.

  • simulated (bool) – Whether to use a simulated actuator board class or an interface to the physical board.

close_port(port: int) int[source]

Closes a particular port.

Parameters

port (int) – The port to close.

Raises
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

int

get_port(port: int) int[source]

Reads the data at a specific port.

Parameters

port (int) – The port to read from.

Raises
Returns

The response served by the board.

Return type

int

open_port(port: int) int[source]

Opens a particular port.

Parameters

port (int) – The port to open.

Raises
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

int

ping() int[source]

Sends a ping message to the board and returns the response.

Raises
Returns

The response from the board.

Return type

int

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
  • port (int) – The specific port to open/close.

  • do_open (bool) – Whether to open the port. If False, then the port is closed.

Raises

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

int

OPEN_RESPONSE

A constant representing a response from the board when the open request is sent. Currently set to 0x01.

Type

int

CLOSE_REQUEST_BASE

A constant representing a request to the board to close a valve. Currently set to 0x30.

Type

int

CLOSE_RESPONSE

A constant representing a response from the board when the close request is sent. Currently set to 0x00.

Type

int

READ_REQUEST_BASE

A constant representing a request to the board to read the value of a valve. Currently set to 0x40.

Type

int

PING_REQUEST

A constant representing a ping request. Currently set to 0x10.

Type

int

PING_RESPONSE

A constant representing a response from the board when the ping request is sent. Currently set to 0x11.

Type

int

CHECKSUM_CODE

The checksum code used by the board. Currently sent to 0xFF.

Type

int

create_checksum(byte: int) int[source]

Creates a checksum given a piece of data. The checksum is calculated through the XOR operation.

Parameters

byte (int) – The data to compute the checksum on.

Returns

The checksum.

Return type

int

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

bytes

serialize_packet(byte: int) bytes[source]

Serializes a piece of data (an integer) into a bytes object.

Returns

The serialized packet.

Return type

bytes

verify_checksum(byte: int, checksum: int) bool[source]

Verifies that two checksums are the same.

Parameters
  • byte (int) – The data to verify the constructed checksum of.

  • checksum (int) – The checksum to validate the constructed checksum against.

Returns

Whether the two checksums are the same.

Return type

bool

SimulatedPnuematicActuatorBoard

Methods
class mil_pneumatic_actuator.SimulatedPnuematicActuatorBoard(*args, **kwargs)[source]

A simulation of the pneumatic actuator board’s serial protocol

write(data: bytes)[source]

Writes a series of bytes and completes the necessary actions.