RTIS Common Library
Common Python library used by the RTIS Network and its various applications
RTIS Common Documentation - Table of Content
General Usage
Several functions are available to be used to gain information on the connected RTIS Clients and Server and prepare your application for their data.
All the available commands are explained in the source documentation or on the Wiki.
For receiving the measurement data one should set up a TCP socket server with the
IP defined in the serversettings.json of the RTIS Server as "applicationIp" with port 65444
.
For example:
import socket
import pickle
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.bind(('applicationIp', 65444))
serverSocket.listen(10)
print("Started data listener.")
while True:
try:
conn, address = serverSocket.accept()
data = []
while True:
packet = conn.recv(2048)
if not packet:
break
data.append(packet)
dataPackage = pickle.loads(b"".join(data))
print("measurement #" + str(dataPackage[4]) + " from RTIS Client '" + dataPackage[0] + "' received!")
except socket.error as ex:
print("the RTIS Server aborted the data connection: " + str(ex))
except pickle.UnpicklingError as ex:
print("the RTIS Server aborted the data connection: " + str(ex))
except EOFError as ex:
print("The RTIS Server aborted the data connection: " + str(ex))
except KeyboardInterrupt:
print("Closing data listener...")
serverSocket.close()
The dataPackage
that the RTIS Network Server sends contains a tuple with the following elements in this order:
-
ID
: string: The RTIS Client ID. -
processedData
: numpy ndarray: The data matrix holding the optionally processed data. -
rawData
: numpy ndarray: The data matrix holding the raw recording data samples as uint32. -
timestamp
: float: Epoch timestamp of when the measurement was taken on the RTIS Client. -
index
: int: The measurement index of this measurement for this RTIS Client. -
behaviour
: int (0 or 1): The behaviour of the RTIS Client sonar mode. 0 means passive, 1 means active.
Classes
RTISClientObj
class RTISClientObj(client_id, client_ip, network_version, firmware_version, required, config_name, client_online=True) [source]
Class describing a connected RTIS Client.
Attributes: |
id : string
The unique identifier to identify this RTIS Client by. ip : stringThe current IP used by the active RTIS Client. online : boolIf the RTIS Client has timed out it will be set to False, otherwise it will always be True. lastHeartbeatTimestamp : datetime.datetimeThe datetime object telling the last time a heartbeat was received from an RTIS Client. configured : intThe state of the configuration of an RTIS Client. 0 = Booting | 1 = Started | 2 = Configuring | 3 = Ready | 4 = Preparing workers | 5 = Online behaviour : intThe state of the sonar behaviour of an RTIS Client. 0 = passive | 1 = active required : intA toggle to state if the sensor is required to be online and stable before measurements can be started. 0 = not required | 1 = required stable : intA state indicator to know if the sensor has been in the 'Ready' state for at least 1 minute to indicate it is fully ready and stable for operation. 0 = not stable yet | 1 = stable startStableTimestamp : datetime.datetimeThe datetime object telling the start time the RTIS Client was in the 'Ready' state. inputDataQueueSize : intThe amount of data packages currently in the incoming data queue of the RTIS Client. outputDataQueueSize : intThe amount of data packages currently in the outgoing data queue of the RTIS Client. internalCounter : intThe current index of the internal measurement counter of the connected RTIS hardware. networkVersion : stringThe RTIS Network software version that is used by this RTIS Client. firmwareVersion : stringThe RTIS Device hardware firmware version that is used by this RTIS Client. |
---|
Methods
update_heartbeat(self, client_ip, client_configured, client_behaviour, client_inputDataQueueSize, client_outputDataQueueSize, client_internalCounter) [source]
Method that is used by RTIS Server to update the status of a RTIS Client when a new heartbeat is received.
Parameters: |
client_ip : string
The current IP used by the active RTIS Client. client_configured : intThe state of the configuration of an RTIS Client. 0 = Booting | 1 = Started | 2 = Configuring | 3 = Ready | 4 = Preparing workers | 5 = Online client_behaviour : intThe state of the sonar behaviour of an RTIS Client. 0 = passive | 1 = active client_inputDataQueueSize : intThe amount of data packages currently in the incoming data queue of the RTIS Client. client_outputDataQueueSize : intThe amount of data packages currently in the outgoing data queue of the RTIS Client. client_internalCounter : intThe current index of the internal measurement counter of the connected RTIS hardware. |
---|
check_heartbeat(self, maximum_delta=15) [source]
Method to check if a RTIS Client has timed out based on a check if it is previous received heartbeat.
Parameters: |
maximum_delta : float (default = 15)
The maximum difference in time between now and the last received heartbeat before being listed as a timed out client. |
---|---|
Returns: |
state : bool
returns |
check_stability(self) [source]
Method to check if a RTIS Client is in the 'ready' configuration state for at least 30 seconds to indicate it is fully ready and stable for operation.
Returns: |
state : bool
returns |
---|
Pose
class Pose(x, y, z, pitch, yaw, roll) [source]
Class describing a 3D pose using the right-handed coordinate system where x points forward, Y points to the left and Z point upwards. Rotations are around these axes also by the right-hand rule with roll being around the X-axis, pitch being around the Y-axis and yaw around the Z-axis. x, y and z are in meters. Pitch, yaw and roll in degrees.
Attributes: |
x : float
The forward facing axis position value in meters. y : floatThe left facing axis position value in meters. z : floatThe upwards facing axis position value in meters. pitch : floatThe rotation value around the Y-axis in degrees. yaw : floatThe rotation value around the Z-axis in degrees. roll : floatThe rotation value around the X-axis in degrees. |
---|
dspSettings
class dspSettings(configName, dspFiles, workers, pdmEnable, preFilterEnable, matchedFilterEnable, beamformingEnable, postFilterEnable, enveloppeEnable, cleanEnable, version) [source]
Class describing all the recording and processing settings related to RTIS devices. Too many variables to describe here. Check the source-code for more information on which variables are available.
Can be converted to a dictionary.
Methods
dsp_worker_process
def dsp_worker_process(dspSettings, inputDataQueue, outputDataQueue, logger =None) [source]
The method to use als a multiprocessing.Process
to perform a DSP pipeline on sonar measurements
using the RTIS CUDA library. This will run continuously until closed.
It will first prepare the DSP pipeline with the given settings. Afterwards it will process each measurement
placed on the input data queue and place the result on the output data queue.
This method should only be used the RTIS Server and not by applications.
The resulting data on the output data queue will be a tuple with the following content:
-
ID
: string: The RTIS Client ID. -
processedData
: numpy ndarray: The data matrix holding the optionally processed data. -
rawData
: numpy ndarray: The data matrix holding the raw recording data samples as uint32. -
timestamp
: float: Epoch timestamp of when the measurement was taken on the RTIS Client. -
index
: int: The measurement index of this measurement for this RTIS Client. -
behaviour
: int (0 or 1): The behaviour of the RTIS Client sonar mode. 0 means passive, 1 means active.
Parameters: |
dspSettings : dspSettings
The complete class containing all RTIS settings for measuring and processing. inputDataQueue : multiprocessing.Manager.QueueThe queue to get the measurement data packages from. outputDataQueue : multiprocessing.Manager.QueueThe queue to put the measurement data packages on after processing. logger : logging.Logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
get_server_config
def get_server_config(serverIp, logger=None) [source]
A method to connect to the RTIS Server and get the dspSettings
currently used by the RTIS Server.
Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|---|
Returns: |
serverDspSettings : dspSettings
The complete class containing all RTIS settings for measuring and processing. Returns None on failure. |
get_clients_and_configs
def get_clients_and_configs(serverIp, logger=None) [source]
A method to connect to the RTIS Server and get all the active connected RTIS Clients
with and their respective dspSettings
.
Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|---|
Returns: |
clients : dictionary (string,dspSettings)
A dictionary with the RTIS Client IDs as the keys and the DSP settings as the values. |
get_client_pose
def get_client_pose(serverIp, client_id, logger=None) [source]
A method to connect to the RTIS Server and get the Pose
of a particular RTIS Client with.
Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. client_id : stringThe identifier of the RTIS Client. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|---|
Returns: |
pose : Pose
The Pose object containing the position and (euler) rotation values of that RTIS Client. Returns None on failure. |
reload_config
def reload_config(serverIp, logger=None) [source]
Tell the RTIS Server to reload its serverconfig.json file and read in the new settings. Will also re-configure all connected RTIS Clients.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
prepare
def prepare(serverIp, logger=None) [source]
Tell the RTIS Server and connected RTIS Clients to start all workers.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
idle
def idle(serverIp, logger=None) [source]
Tell the RTIS Server and connected RTIS Clients to go idle and stop all measurements and kill all running workers.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
stop
def stop(serverIp, logger=None) [source]
Tell the RTIS Server and connected RTIS Clients to stop any running measurements.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
start
def start(serverIp, measurements=0, frequency=0, active='0', logger=None) [source]
Tell the RTIS Server and connected RTIS Clients to stop any running measurements.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. measurements : intSet a custom amount of measurements to record. If argument is not given it will be set to 0. Which results in continuous and infinite measurements. frequency : intSet a custom measurement frequency. If not given will take the default set in the serversettings.json file. active : stringSet a custom list of active connections for the RTIS Sync device. If not given will take the default set in the serversettings.json file. Format: "X,X,X,X,X,X" where X is 1(active) or 0(inactive). logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
set_counter
def set_counter(serverIp, index=0, logger=None) [source]
A method to connect to the RTIS Server tell all connected RTIS Clients to set their sonar behaviour to active. Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. index : intThe new index to set the internal measurement counter on. Defaults to 0 if not given. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
set_behaviour_active
def set_behaviour_active(serverIp, logger=None) [source]
A method to connect to the RTIS Server tell all connected RTIS Clients to set their sonar behaviour to active. Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|
set_behaviour_passive
def set_behaviour_passive(serverIp, logger=None) [source]
A method to connect to the RTIS Server tell all connected RTIS Clients to set their sonar behaviour to passive. Useful for connected applications.
Parameters: |
serverIp : string
The IP on which the RTIS Server can be found. logger : logging.logger (default = None)The logging library object to stream the messages to. If None then normal Print statement is used. |
---|