wrapyfi.servers package
Submodules
wrapyfi.servers.ros module
- class wrapyfi.servers.ros.ROSServer(name: str, out_topic: str, carrier: str = 'tcp', ros_kwargs: dict | None = None, **kwargs)[source]
Bases:
Server
- __init__(name: str, out_topic: str, carrier: str = 'tcp', ros_kwargs: dict | None = None, **kwargs)[source]
Initialize the server.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
ros_kwargs – dict: Additional kwargs for the ROS middleware
kwargs – dict: Additional kwargs for the server
- class wrapyfi.servers.ros.ROSNativeObjectServer(name: str, out_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSServer
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.ros.ROSImageServer(name: str, out_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSServer
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
width – int: Width of the image. Default is -1 (use the width of the received image)
height – int: Height of the image. Default is -1 (use the height of the received image)
rgb – bool: True if the image is RGB, False if it is grayscale. Default is True
fp – bool: True if the image is floating point, False if it is integer. Default is False
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.ros.ROSAudioChunkServer(name: str, out_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSServer
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling audio data as numpy arrays.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
channels – int: Number of channels in the audio. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: Number of samples in the audio chunk. Default is -1 (use the chunk size of the received audio)
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
wrapyfi.servers.ros2 module
- class wrapyfi.servers.ros2.ROS2Server(name: str, out_topic: str, ros2_kwargs: dict | None = None, **kwargs)[source]
Bases:
Server
,Node
- __init__(name: str, out_topic: str, ros2_kwargs: dict | None = None, **kwargs)[source]
Initialize the server.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
ros2_kwargs – dict: Additional kwargs for the ROS 2 middleware
kwargs – dict: Additional kwargs for the server
- class wrapyfi.servers.ros2.ROS2NativeObjectServer(name: str, out_topic: str, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROS2Server
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.ros2.ROS2ImageServer(name: str, out_topic: str, width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROS2Server
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
width – int: Width of the image. Default is -1 (use the width of the received image)
height – int: Height of the image. Default is -1 (use the height of the received image)
rgb – bool: True if the image is RGB, False if it is grayscale. Default is True
fp – bool: True if the image is floating point, False if it is integer. Default is False
jpg – bool: True if the image should be decompressed from JPG. Default is False
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.ros2.ROS2AudioChunkServer(name: str, out_topic: str, channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROS2Server
- SEND_QUEUE = <queue.Queue object>
- RECEIVE_QUEUE = <queue.Queue object>
- __init__(name: str, out_topic: str, channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling audio data as numpy arrays.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
channels – int: Number of channels in the audio. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: Number of samples in the audio chunk. Default is -1 (use the chunk size of the received audio)
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
wrapyfi.servers.yarp module
- class wrapyfi.servers.yarp.YarpServer(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, yarp_kwargs: dict | None = None, **kwargs)[source]
Bases:
Server
- __init__(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, yarp_kwargs: dict | None = None, **kwargs)[source]
Initialize the server.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
out_topic_connect – str: Name of the output topic connection alias ‘/’ (e.g. ‘/topic:out’) to connect to. None appends ‘:out’ to the out_topic. Default is None
yarp_kwargs – dict: Additional kwargs for the Yarp middleware
kwargs – dict: Additional kwargs for the server
- class wrapyfi.servers.yarp.YarpNativeObjectServer(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpServer
- __init__(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
out_topic_connect – str: Name of the output topic connection alias ‘/’ (e.g. ‘/topic:out’) to connect to. None appends ‘:out’ to the out_topic. Default is None
persistent – bool: Whether the server port should remain connected after closure. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.yarp.YarpImageServer(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpNativeObjectServer
- __init__(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling image data as numpy arrays, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
out_topic_connect – str: Name of the output topic connection alias ‘/’ (e.g. ‘/topic:out’) to connect to. None appends ‘:out’ to the out_topic. Default is None
persistent – bool: Whether the server port should remain connected after closure. Default is True
width – int: Width of the image. Default is -1 (use the width of the received image)
height – int: Height of the image. Default is -1 (use the height of the received image)
rgb – bool: True if the image is RGB, False if it is grayscale. Default is True
fp – bool: True if the image is floating point, False if it is integer. Default is False
deserializer_kwargs – dict: Additional kwargs for the deserializer
- class wrapyfi.servers.yarp.YarpAudioChunkServer(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpNativeObjectServer
- __init__(name: str, out_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', out_topic_connect: str | None = None, persistent: bool = True, channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling audio data as numpy arrays, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Name of the output topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
out_topic_connect – str: Name of the output topic connection alias ‘/’ (e.g. ‘/topic:out’) to connect to. None appends ‘:out’ to the out_topic. Default is None
persistent – bool: Whether the server port should remain connected after closure. Default is True
channels – int: Number of channels in the audio. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: Number of samples in the audio chunk. Default is -1 (use the chunk size of the received audio)
deserializer_kwargs – dict: Additional kwargs for the deserializer
wrapyfi.servers.zeromq module
- class wrapyfi.servers.zeromq.ZeroMQServer(name: str, out_topic: str, carrier: str = 'tcp', socket_ip: str = '127.0.0.1', socket_rep_port: int = 5558, socket_req_port: int = 5559, start_proxy_broker: bool = True, proxy_broker_spawn: bool = 'process', zeromq_kwargs: dict | None = None, **kwargs)[source]
Bases:
Server
- __init__(name: str, out_topic: str, carrier: str = 'tcp', socket_ip: str = '127.0.0.1', socket_rep_port: int = 5558, socket_req_port: int = 5559, start_proxy_broker: bool = True, proxy_broker_spawn: bool = 'process', zeromq_kwargs: dict | None = None, **kwargs)[source]
Initialize the server and start the device broker if necessary.
- Parameters:
name – str: Name of the server
out_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol. ZeroMQ currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
socket_ip – str: IP address of the socket. Default is ‘127.0.0.1’
socket_rep_port – int: Port of the socket for REP pattern. Default is 5558
socket_req_port – int: Port of the socket for REQ pattern. Default is 5559
start_proxy_broker – bool: Whether to start a device broker. Default is True
proxy_broker_spawn – str: Whether to spawn the device broker as a process or thread. Default is ‘process’
zeromq_kwargs – dict: Additional kwargs for the ZeroMQ Req/Rep middleware
kwargs – dict: Additional kwargs for the server
- class wrapyfi.servers.zeromq.ZeroMQNativeObjectServer(name: str, out_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQServer
- __init__(name: str, out_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol. ZeroMQ currently only supports TCP for PUB/SUB pattern. Default is ‘tcp’
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- await_request(*args, **kwargs)[source]
Await and deserialize the client’s request, returning the extracted arguments and keyword arguments. The method blocks until a message is received, then attempts to deserialize it using the configured JSON decoder hook, returning the extracted arguments and keyword arguments.
- Returns:
Tuple[list, dict]: A tuple containing two items: - A list of arguments extracted from the received message - A dictionary of keyword arguments extracted from the received message
- class wrapyfi.servers.zeromq.ZeroMQImageServer(name: str, out_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQNativeObjectServer
- __init__(name: str, out_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling image data as numpy arrays, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol. ZeroMQ currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
width – int: Width of the image. Default is -1 (use the width of the received image)
height – int: Height of the image. Default is -1 (use the height of the received image)
rgb – bool: True if the image is RGB, False if it is grayscale. Default is True
fp – bool: True if the image is floating point, False if it is integer. Default is False
jpg – bool: True if the image should be decompressed from JPG. Default is False
deserializer_kwargs – dict: Additional kwargs for the deserializer
- class wrapyfi.servers.zeromq.ZeroMQAudioChunkServer(name: str, out_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQNativeObjectServer
- __init__(name: str, out_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific server handling audio data as numpy arrays, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the server
out_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol. ZeroMQ currently only supports TCP for REQ/REP pattern. Default is ‘tcp’
channels – int: Number of channels in the audio. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: Number of samples in the audio chunk. Default is -1 (use the chunk size of the received audio)
deserializer_kwargs – dict: Additional kwargs for the deserializer
Module contents
- class wrapyfi.servers.FallbackServer(name: str, out_topic: str, carrier: str = '', missing_middleware_object: str = '', **kwargs)[source]
Bases:
Server
- __init__(name: str, out_topic: str, carrier: str = '', missing_middleware_object: str = '', **kwargs)[source]
Initialize the server.
- Parameters:
name – str: The name of the server
out_topic – str: The topic to publish to
carrier – str: The middleware carrier to use
out_topic_connect – str: The topic to connect to (this is deprecated and will be removed in the future since its usage is limited to YARP)