wrapyfi.middlewares package

Submodules

wrapyfi.middlewares.ros module

class wrapyfi.middlewares.ros.ROSMiddleware(*args, **kwargs)[source]

Bases: object

ROS middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

static activate(**kwargs)[source]

Activate the ROS middleware. This method should be called to initialize the middleware.

Parameters:

kwargs – dict: Keyword arguments to be passed to the ROS initialization function

__init__(node_name: str = 'wrapyfi', anonymous: bool = True, disable_signals: bool = True, *args, **kwargs)[source]

Initialize the ROS middleware. This method is automatically called when the class is instantiated.

Parameters:
  • node_name – str: The name of the ROS node

  • anonymous – bool: Whether the ROS node should be anonymous

  • disable_signals – bool: Whether the ROS node should disable signals

  • args – list: Positional arguments to be passed to the ROS initialization function

  • kwargs – dict: Keyword arguments to be passed to the ROS initialization function

static deinit()[source]

Deinitialize the ROS middleware. This method is automatically called when the program exits.

class wrapyfi.middlewares.ros.ROSNativeObjectService[source]

Bases: object

class wrapyfi.middlewares.ros.ROSImageService[source]

Bases: object

wrapyfi.middlewares.ros2 module

class wrapyfi.middlewares.ros2.ROS2Middleware(*args, **kwargs)[source]

Bases: object

ROS 2 middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

static activate(**kwargs)[source]

Activate the ROS 2 middleware. This method should be called to initialize the middleware.

Parameters:

kwargs – dict: Keyword arguments to be passed to the ROS 2 initialization function

__init__(*args, **kwargs)[source]

Initialize the ROS 2 middleware. This method is automatically called when the class is instantiated.

Parameters:
  • args – list: Positional arguments to be passed to the ROS 2 initialization function

  • kwargs – dict: Keyword arguments to be passed to the ROS 2 initialization function

static deinit()[source]

Deinitialize the ROS 2 middleware. This method is automatically called when the program exits.

wrapyfi.middlewares.yarp module

class wrapyfi.middlewares.yarp.YarpMiddleware(*args, **kwargs)[source]

Bases: object

YARP middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

static activate(**kwargs)[source]

Activate the YARP middleware. This method should be called to initialize the middleware.

Parameters:

kwargs – dict: Keyword arguments to be passed to the YARP initialization function

__init__(*args, **kwargs)[source]

Initialize the YARP middleware. This method is automatically called when the class is instantiated.

static deinit()[source]

Deinitialize the YARP middleware. This method is automatically called when the program exits.

wrapyfi.middlewares.zeromq module

class wrapyfi.middlewares.zeromq.ZeroMQMiddlewarePubSub(*args, **kwargs)[source]

Bases: object

ZeroMQ PUB/SUB middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

class ZeroMQSharedMonitorData(use_multiprocessing: bool = False)[source]

Bases: object

Shared data class for the ZeroMQ PUB/SUB monitor. This class is used to share data between the main process and the monitor listener process/thread.

__init__(use_multiprocessing: bool = False)[source]

Initialize the shared data class.

Parameters:

use_multiprocessing – bool: Whether to use multiprocessing or threading

add_topic(topic: str)[source]

Add a topic to the shared data class.

Parameters:

topic – str: The topic to add

remove_topic(topic: str)[source]

Remove a topic from the shared data class.

Parameters:

topic – str: The topic to remove

get_topics()[source]

Get the list of topics in the shared data class.

Returns:

list: The list of topics

update_connection(topic: str, data: dict)[source]

Update the connection data for a topic, e.g. the number of subscribers.

Parameters:
  • topic – str: The topic to update

  • data – dict: The connection data

remove_connection(topic: str)[source]

Remove the connection data for a topic.

Parameters:

topic – str: The topic to remove

get_connections()[source]

Get the connection data for all topics.

Returns:

dict: The connection data for all topics

is_connected(topic: str)[source]

Check whether a topic is connected.

Parameters:

topic – str: The topic to check

static activate(**kwargs)[source]

Activate the ZeroMQ PUB/SUB middleware. This method should be called to initialize the middleware.

Parameters:

kwargs – dict: Keyword arguments to be passed to the ZeroMQ initialization function

__init__(zeromq_proxy_kwargs: dict | None = None, zeromq_post_kwargs: dict | None = None, **kwargs)[source]

Initialize the ZeroMQ PUB/SUB middleware. This method is automatically called when the class is instantiated.

Parameters:
  • zeromq_proxy_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ proxy initialization function

  • zeromq_post_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ initialization function (these are ZeroMQ options)

  • kwargs – dict: Keyword arguments to be passed to the ZeroMQ initialization function

static proxy_thread(socket_pub_address: str = 'tcp://127.0.0.1:5555', socket_sub_address: str = 'tcp://127.0.0.1:5556', inproc_address: str = 'inproc://monitor')[source]

Proxy thread for the ZeroMQ PUB/SUB proxy.

Parameters:
  • socket_pub_address – str: The address of the PUB socket

  • socket_sub_address – str: The address of the SUB socket

  • inproc_address – str: The address of the inproc socket (connections within the same process, for exchanging subscription data between the proxy and the monitor)

static subscription_monitor_thread(inproc_address: str = 'inproc://monitor', socket_sub_address: str = 'tcp://127.0.0.1:5556', pubsub_monitor_topic: str = 'ZEROMQ/CONNECTIONS', verbose: bool = False)[source]

Subscription monitor thread for the ZeroMQ PUB/SUB proxy.

Parameters:
  • inproc_address – str: The address of the inproc socket (connections within the same process, for exchanging subscription data between the proxy and the monitor)

  • socket_sub_address – str: The address of the SUB socket

  • pubsub_monitor_topic – str: The topic to use for publishing subscription data

  • verbose – bool: Whether to print debug messages

static deinit()[source]
class wrapyfi.middlewares.zeromq.ZeroMQMiddlewareReqRep(*args, **kwargs)[source]

Bases: object

ZeroMQ REQ/REP middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

static activate(**kwargs)[source]

Activate the ZeroMQ REQ/REP middleware. This method should be called to initialize the middleware.

Parameters:

kwargs – dict: Keyword arguments to be passed to the ZeroMQ initialization function

__init__(zeromq_proxy_kwargs: dict | None = None, zeromq_post_kwargs: dict | None = None, *args, **kwargs)[source]

Initialize the ZeroMQ REQ/REP middleware. This method is automatically called when the class is instantiated.

Parameters:
  • zeromq_proxy_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ proxy initialization function

  • zeromq_post_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ initialization function (these are ZeroMQ options)

  • args – list: Positional arguments to be passed to the ZeroMQ initialization function

  • kwargs – dict: Keyword arguments to be passed to the ZeroMQ initialization function

static deinit()[source]
class wrapyfi.middlewares.zeromq.ZeroMQMiddlewareParamServer(*args, **kwargs)[source]

Bases: object

ZeroMQ parameter server middleware wrapper. This class is a singleton, so it can be instantiated only once. The activate method should be called to initialize the middleware. The deinit method should be called to deinitialize the middleware and destroy all connections. The activate and deinit methods are automatically called when the class is instantiated and when the program exits, respectively.

Note: This parameter server is experimental and not fully tested.

static activate(**kwargs)[source]
__init__(zeromq_proxy_kwargs: dict | None = None, zeromq_post_kwargs: Optional = None, *args, **kwargs)[source]

Initialize the ZeroMQ parameter server middleware. This method is automatically called when the class is instantiated.

Parameters:
  • zeromq_proxy_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ proxy initialization function

  • zeromq_post_kwargs – Optional[dict]: Keyword arguments to be passed to the ZeroMQ initialization function (these are ZeroMQ options)

  • kwargs – dict: Keyword arguments to be passed to the ZeroMQ initialization function

static publish_params(param_server, params: dict, cached_params: dict, root_topics: set, update_trigger: bool)[source]

Publish parameters to the parameter server.

Parameters:
  • param_server – zmq.Socket: The parameter server socket

  • params – dict: The parameters to be published

  • cached_params – dict: The cached parameters. This is used to check whether the parameters have changed

  • root_topics – set: The root topics. This is used to check whether there are any active subscribers

  • update_trigger – bool: Whether to trigger an update of the parameters

Returns:

Tuple[bool, dict]: Whether to trigger an update of the parameters and the cached parameters

static deinit()[source]

Deinitialize the ZeroMQ parameter server.

Module contents