wrapyfi.clients package
Submodules
wrapyfi.clients.ros module
- class wrapyfi.clients.ros.ROSClient(name: str, in_topic: str, carrier: str = 'tcp', ros_kwargs: dict | None = None, **kwargs)[source]
Bases:
Client
- __init__(name: str, in_topic: str, carrier: str = 'tcp', ros_kwargs: dict | None = None, **kwargs)[source]
Initialize the client.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for rep/req pattern. Default is ‘tcp’
ros_kwargs – dict: Additional kwargs for the ROS middleware
kwargs – dict: Additional kwargs for the client
- class wrapyfi.clients.ros.ROSNativeObjectClient(name: str, in_topic: str, carrier: str = 'tcp', persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
The NativeObject client using the ROS String message assuming the data is serialized as a JSON string. Deserializes the data (including plugins) using the decoder and parses it to a Python object.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for rep/req pattern. Default is ‘tcp’
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- class wrapyfi.clients.ros.ROSImageClient(name: str, in_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, persistent: bool = True, rgb: bool = True, fp: bool = False, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, persistent: bool = True, rgb: bool = True, fp: bool = False, serializer_kwargs: dict | None = None, **kwargs)[source]
The Image client using the ROS Image message parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for rep/req pattern. Default is ‘tcp’
width – int: The width of the image. Default is -1
height – int: The height of the image. Default is -1
rgb – bool: Whether the image is RGB. Default is True
fp – bool: Whether to utilize floating-point precision. Default is False
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
- class wrapyfi.clients.ros.ROSAudioChunkClient(name: str, in_topic: str, carrier: str = 'tcp', persistent: bool = True, channels: int = 1, rate: int = 44100, chunk: int = -1, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ROSClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', persistent: bool = True, channels: int = 1, rate: int = 44100, chunk: int = -1, serializer_kwargs: dict | None = None, **kwargs)[source]
The AudioChunk client using the ROS Audio message parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol. ROS currently only supports TCP for rep/req pattern. Default is ‘tcp’
channels – int: Number of audio channels. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: The size of audio chunks. Default is -1
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
wrapyfi.clients.ros2 module
- class wrapyfi.clients.ros2.ROS2Client(*args: Any, **kwargs: Any)[source]
Bases:
Client
,Node
- __init__(name: str, in_topic: str, ros2_kwargs: dict | None = None, **kwargs)[source]
Initialize the client.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
ros2_kwargs – dict: Additional kwargs for the ROS 2 middleware
kwargs – dict: Additional kwargs for the client
- class wrapyfi.clients.ros2.ROS2NativeObjectClient(*args: Any, **kwargs: Any)[source]
Bases:
ROS2Client
- __init__(name: str, in_topic: str, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
The NativeObject listener using the ROS 2 String message assuming the data is serialized as a JSON string. Deserializes the data (including plugins) using the decoder and parses it to a Python object.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- class wrapyfi.clients.ros2.ROS2ImageClient(*args: Any, **kwargs: Any)[source]
Bases:
ROS2Client
- __init__(name: str, in_topic: str, width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, serializer_kwargs: dict | None = None, **kwargs)[source]
The Image client using the ROS 2 Image message parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
width – int: The width of the image. Default is -1 (use the width of the received image)
height – int: The height of the image. Default is -1 (use the height of the received image)
rgb – bool: Whether the image is RGB. Default is True
fp – bool: Whether to utilize floating-point precision. Default is False
jpg – bool: True if the image should be decompressed from JPG. Default is False
serializer_kwargs – dict: Additional kwargs for the serializer
- class wrapyfi.clients.ros2.ROS2AudioChunkClient(*args: Any, **kwargs: Any)[source]
Bases:
ROS2Client
- __init__(name: str, in_topic: str, channels: int = 1, rate: int = 44100, chunk: int = -1, serializer_kwargs: dict | None = None, **kwargs)[source]
The AudioChunk client using the ROS 2 Audio message parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input 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)
serializer_kwargs – dict: Additional kwargs for the serializer
wrapyfi.clients.yarp module
- class wrapyfi.clients.yarp.YarpClient(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', persistent: bool = True, yarp_kwargs: dict | None = None, **kwargs)[source]
Bases:
Client
- __init__(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', persistent: bool = True, yarp_kwargs: dict | None = None, **kwargs)[source]
Initialize the client.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
yarp_kwargs – dict: Additional kwargs for the Yarp middleware
kwargs – dict: Additional kwargs for the client
- class wrapyfi.clients.yarp.YarpNativeObjectClient(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpClient
- __init__(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', persistent: bool = True, serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
The NativeObject listener using the YARP Bottle construct assuming the data is serialized as a JSON string. Deserializes the data (including plugins) using the decoder and parses it to a Python object.
- Parameters:
name – str: Name of the client
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
kwargs – dict: Additional kwargs for the client
- class wrapyfi.clients.yarp.YarpImageClient(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, persistent: bool = True, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpNativeObjectClient
- __init__(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, persistent: bool = True, serializer_kwargs: dict | None = None, **kwargs)[source]
The Image client using the YARP Bottle construct parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
width – int: The width of the image. Default is -1
height – int: The height of the image. Default is -1
rgb – bool: Whether the image is RGB. Default is True
fp – bool: Whether to utilize floating-point precision. Default is False
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
- class wrapyfi.clients.yarp.YarpAudioChunkClient(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, persistent: bool = True, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
YarpNativeObjectClient
- __init__(name: str, in_topic: str, carrier: Literal['tcp', 'udp', 'mcast'] = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, persistent: bool = True, serializer_kwargs: dict | None = None, **kwargs)[source]
The AudioChunk client using the YARP Bottle construct parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Name of the input topic preceded by ‘/’ (e.g. ‘/topic’)
carrier – str: Carrier protocol (e.g. ‘tcp’). Default is ‘tcp’
channels – int: Number of audio channels. Default is 1
rate – int: Sampling rate of the audio. Default is 44100
chunk – int: The size of audio chunks. Default is -1
persistent – bool: Whether to keep the service connection alive across multiple service calls. Default is True
serializer_kwargs – dict: Additional kwargs for the serializer
wrapyfi.clients.zeromq module
- class wrapyfi.clients.zeromq.ZeroMQClient(name, in_topic, carrier='tcp', socket_ip: str = '127.0.0.1', socket_rep_port: int = 5558, zeromq_kwargs: dict | None = None, **kwargs)[source]
Bases:
Client
- __init__(name, in_topic, carrier='tcp', socket_ip: str = '127.0.0.1', socket_rep_port: int = 5558, zeromq_kwargs: dict | None = None, **kwargs)[source]
Initialize the client.
- Parameters:
name – str: Name of the client
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’
zeromq_kwargs – dict: Additional kwargs for the ZeroMQ middleware
kwargs – dict: Additional kwargs for the client
- class wrapyfi.clients.zeromq.ZeroMQNativeObjectClient(name: str, in_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', serializer_kwargs: dict | None = None, deserializer_kwargs: dict | None = None, **kwargs)[source]
Specific client for handling native Python objects, serializing them to JSON strings for transmission.
- Parameters:
name – str: Name of the client
in_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’
serializer_kwargs – dict: Additional kwargs for the serializer
deserializer_kwargs – dict: Additional kwargs for the deserializer
- request(*args, **kwargs)[source]
Serialize the provided Python objects to JSON strings, send a request to the server, and await a reply. The method uses the configured JSON encoder for serialization before sending the resultant string to the server.
- Parameters:
args – tuple: Arguments to be sent to the server
kwargs – dict: Keyword arguments to be sent to the server
- Returns:
Any: The Python object received from the server, deserialized using the configured JSON decoder hook
- class wrapyfi.clients.zeromq.ZeroMQImageClient(name: str, in_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQNativeObjectClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', width: int = -1, height: int = -1, rgb: bool = True, fp: bool = False, jpg: bool = False, serializer_kwargs: dict | None = None, **kwargs)[source]
The Image client using the ZeroMQ message construct parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol (e.g. ‘tcp’). 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 compressed to JPG before sending. Default is False
serializer_kwargs – dict: Additional kwargs for the serializer
- class wrapyfi.clients.zeromq.ZeroMQAudioChunkClient(name: str, in_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, serializer_kwargs: dict | None = None, **kwargs)[source]
Bases:
ZeroMQNativeObjectClient
- __init__(name: str, in_topic: str, carrier: str = 'tcp', channels: int = 1, rate: int = 44100, chunk: int = -1, serializer_kwargs: dict | None = None, **kwargs)[source]
The AudioChunk client using the ZeroMQ message construct parsed to a numpy array.
- Parameters:
name – str: Name of the client
in_topic – str: Topics are not supported for the REQ/REP pattern in ZeroMQ. Any given topic is ignored
carrier – str: Carrier protocol (e.g. ‘tcp’). 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 compressed to JPG before sending. Default is False
serializer_kwargs – dict: Additional kwargs for the serializer
Module contents
- class wrapyfi.clients.FallbackClient(name: str, in_topic: str, carrier: str = '', missing_middleware_object: str = '', **kwargs)[source]
Bases:
Client