ping-python
A python implementation of the Blue Robotics Ping messaging protocol and a device API for the Blue Robotics Ping1D echosounder.
 All Classes Functions Variables
Public Member Functions | Public Attributes | List of all members
Ping.Ping1D.Ping1D Class Reference
Inheritance diagram for Ping.Ping1D.Ping1D:
Inheritance graph
[legend]
Collaboration diagram for Ping.Ping1D.Ping1D:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def read
 Consume rx buffer data until a new message is successfully decoded. More...
 
def write
 Write data to device.
 
def initialize
 Make sure there is a device on the line and read some initial data Return True if the device replies with expected data Return False otherwise.
 
def request
 Request the given message ID Return response if it is rxed within timeout period, None otherwise TODO handle nack to exit without blocking.
 
def waitReply
 Wait for the device to send a message with the desired message_id for timeout s Return True if a valid message is received from the device with the desired message_id before the timeout period expires Return False otherwise.
 
def handleMessage
 Handle an incoming messge from the device Extract message fields into self attributes.
 
def __repr__
 Dump object into string representation.
 
def get_fw_version
 Request a message from the device If there is no reply return None, otherwise return a dictionary of the updated values. More...
 
def get_device_id
 The device ID. More...
 
def get_voltage_5
 The 5V rail voltage. More...
 
def get_speed_of_sound
 The speed of sound used for distance calculations. More...
 
def get_range
 The scan range for acoustic measurements. More...
 
def get_mode_auto
 The current operating mode of the device. More...
 
def get_ping_rate
 The interval between acoustic measurements. More...
 
def get_gain_index
 The current gain setting. More...
 
def get_pulse_usec
 The duration of the acoustic activation/transmission. More...
 
def get_general_info
 General information. More...
 
def get_distance_simple
 The distance to target with confidence estimate. More...
 
def get_distance
 Returns a dictionary of the reply payload. More...
 
def get_processor_temperature
 Temperature of the device cpu. More...
 
def get_pcb_temperature
 Temperature of the on-board thermistor. More...
 
def get_profile
 A profile produced from a single acoustic measurement. More...
 
def get_protocol_version
 The protocol version Returns a dictionary of the reply payload. More...
 
def set_device_id
 Write a new control, and read the values back from the device If verify is true, fail if the values read back from the device do not match the controls that were written Return True on success Return False on failure to read values back or on verification failure. More...
 
def set_range
 Set the scan range for acoustic measurements. More...
 
def set_speed_of_sound
 Set the speed of sound used for distance calculations. More...
 
def set_mode_auto
 Set automatic or manual mode. More...
 
def set_ping_rate
 The interval between acoustic measurements. More...
 
def set_gain_index
 Set the current gain selection. More...
 
def set_ping_enable
 Enable or disable acoustic measurements. More...
 

Public Attributes

 iodev
 Serial object for device communication.
 
 parser
 A helper class to take care of decoding the input stream.
 
 my_id
 device id of this Ping1D object, used for dst_device_id in outgoing messages
 

Member Function Documentation

def Ping.Ping1D.Ping1D.get_device_id (   self)

The device ID.

Returns a dictionary of the reply payload

Returns
device_id: The device ID (0-254). 255 is reserved for broadcast messages.
def Ping.Ping1D.Ping1D.get_distance (   self)

Returns a dictionary of the reply payload.

Returns
distance: Units: mm; The current return distance determined for the most recent acoustic measurement.
confidence: Units: %; Confidence in the most recent range measurement.
pulse_usec: Units: us; The acoustic pulse length during acoustic transmission/activation.
ping_number: The pulse/measurement count since boot.
scan_start: Units: mm; The beginning of the scan region in mm from the transducer.
scan_length: Units: mm; The length of the scan region.
gain_index: The current gain setting. 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB
def Ping.Ping1D.Ping1D.get_distance_simple (   self)

The distance to target with confidence estimate.

Returns a dictionary of the reply payload

Returns
distance: Units: mm; Distance to the target.
confidence: Units: %; Confidence in the distance measurement.
def Ping.Ping1D.Ping1D.get_fw_version (   self)

Request a message from the device If there is no reply return None, otherwise return a dictionary of the updated values.

Device information Returns a dictionary of the reply payload

Returns
device_type: Device type. 0: 1D Echosounder
device_model: Device model. 0: Ping1D
fw_version_major: Firmware version major number.
fw_version_minor: Firmware version minor number.
def Ping.Ping1D.Ping1D.get_gain_index (   self)

The current gain setting.

Returns a dictionary of the reply payload

Returns
gain_index: 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB
def Ping.Ping1D.Ping1D.get_general_info (   self)

General information.

Returns a dictionary of the reply payload

Returns
fw_version_major: Firmware major version.
fw_version_minor: Firmware minor version.
mvolts: Units: mV; Device supply voltage.
ping_rate: Units: ms; The interval between acoustic measurements.
gain_index: The current gain setting. 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB
mode_auto: The current operating mode of the device. 0: manual mode, 1: auto mode
def Ping.Ping1D.Ping1D.get_mode_auto (   self)

The current operating mode of the device.

Manual mode allows for manual selection of the gain and scan range. Returns a dictionary of the reply payload

Returns
mode_auto: 0: manual mode, 1: auto mode
def Ping.Ping1D.Ping1D.get_pcb_temperature (   self)

Temperature of the on-board thermistor.

Returns a dictionary of the reply payload

Returns
temp: Units: cC; The temperature in centi-degrees Centigrade (100 * degrees C).
def Ping.Ping1D.Ping1D.get_ping_rate (   self)

The interval between acoustic measurements.

Returns a dictionary of the reply payload

Returns
ping_rate: Units: ms; The interval between acoustic measurements.
def Ping.Ping1D.Ping1D.get_processor_temperature (   self)

Temperature of the device cpu.

Returns a dictionary of the reply payload

Returns
temp: Units: cC; The temperature in centi-degrees Centigrade (100 * degrees C).
def Ping.Ping1D.Ping1D.get_profile (   self)

A profile produced from a single acoustic measurement.

The data returned is an array of response strength at even intervals across the scan region. The scan region defined the region between <scan_start> and <scan_start + scan_length> millimeters away from the transducer. A distance measurement to the target is also provided. Returns a dictionary of the reply payload

Returns
distance: Units: mm; The current return distance determined for the most recent acoustic measurement.
confidence: Units: %; Confidence in the most recent range measurement.
pulse_usec: Units: us; The acoustic pulse length during acoustic transmission/activation.
ping_number: The pulse/measurement count since boot.
scan_start: Units: mm; The beginning of the scan region in mm from the transducer.
scan_length: Units: mm; The length of the scan region.
gain_index: The current gain setting. 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB
num_points: The number of data points for the profile. (The length of the proceeding array)
data: An array of return strength measurements taken at regular intervals across the scan region.
def Ping.Ping1D.Ping1D.get_protocol_version (   self)

The protocol version Returns a dictionary of the reply payload.

Returns
protocol_version:
def Ping.Ping1D.Ping1D.get_pulse_usec (   self)

The duration of the acoustic activation/transmission.

Returns a dictionary of the reply payload

Returns
pulse_usec: Units: microseconds; Acoustic pulse duration.
def Ping.Ping1D.Ping1D.get_range (   self)

The scan range for acoustic measurements.

Measurements returned by the device will lie in the range (scan_start, scan_start + scan_length). Returns a dictionary of the reply payload

Returns
scan_start: Units: mm; The beginning of the scan range in mm from the transducer.
scan_length: Units: mm; The length of the scan range.
def Ping.Ping1D.Ping1D.get_speed_of_sound (   self)

The speed of sound used for distance calculations.

Returns a dictionary of the reply payload

Returns
speed_of_sound: Units: mm/s; The speed of sound in the measurement medium. ~1,500,000 mm/s for water.
def Ping.Ping1D.Ping1D.get_voltage_5 (   self)

The 5V rail voltage.

Returns a dictionary of the reply payload

Returns
mvolts: Units: mV; The 5V rail voltage.
def Ping.Ping1D.Ping1D.read (   self)

Consume rx buffer data until a new message is successfully decoded.

Returns
A new PingMessage: as soon as a message is parsed (there may be data remaining in the buffer to be parsed, thus requiring subsequent calls to read())
None: if the buffer is empty and no message has been parsed
def Ping.Ping1D.Ping1D.set_device_id (   self,
  device_id,
  verify = True 
)

Write a new control, and read the values back from the device If verify is true, fail if the values read back from the device do not match the controls that were written Return True on success Return False on failure to read values back or on verification failure.

Set the device ID.

Parameters
device_id- Device ID (0-254). 255 is reserved for broadcast messages.
def Ping.Ping1D.Ping1D.set_gain_index (   self,
  gain_index,
  verify = True 
)

Set the current gain selection.

Parameters
gain_index- 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB
def Ping.Ping1D.Ping1D.set_mode_auto (   self,
  mode_auto,
  verify = True 
)

Set automatic or manual mode.

Manual mode allows for manual selection of the gain and scan range.

Parameters
mode_auto- 0: manual mode. 1: auto mode.
def Ping.Ping1D.Ping1D.set_ping_enable (   self,
  enable,
  verify = True 
)

Enable or disable acoustic measurements.

Parameters
enable- 0: Disable, 1: Enable.
def Ping.Ping1D.Ping1D.set_ping_rate (   self,
  ping_rate,
  verify = True 
)

The interval between acoustic measurements.

Parameters
ping_rate- Units: ms; The interval between acoustic measurements.
def Ping.Ping1D.Ping1D.set_range (   self,
  scan_start,
  scan_length,
  verify = True 
)

Set the scan range for acoustic measurements.

Parameters
scan_start- Units: mm; Set the scan range for acoustic measurements.
scan_length- Units: mm; The length of the scan range.
def Ping.Ping1D.Ping1D.set_speed_of_sound (   self,
  speed_of_sound,
  verify = True 
)

Set the speed of sound used for distance calculations.

Parameters
speed_of_sound- Units: mm/s; The speed of sound in the measurement medium. ~1,500,000 mm/s for water.

The documentation for this class was generated from the following file: