bob_transformers.base

Base ROS Node for package bob_transformers.

Classes

Base

Lifecycle ROS Node

BaseNode

Lifecycle ROS Node

Module Contents

class bob_transformers.base.Base(node_name, *, enable_communication_interface: bool = True, **kwargs)

Bases: bob_transformers.lnode.LNode

Lifecycle ROS Node

class bob_transformers.base.BaseNode(node_name)

Bases: Base

Lifecycle ROS Node

publisher = []
subscriber = []
destroy()

Handle destroy for lifecycle node.

add_subscriber(class_type: Any, topic: str, callback, queue_size: int = 100)

Adds a subscriber.

Args:

class_type (Any): Message class of the topic. topic (str): The topic location. callback (function): Callback function which receives the message. queue_size (int, optional): Queue size. Defaults to 100.

Returns:

Subscriber: The created subscriber instance.

add_publisher(class_type: Any, topic: str, queue_size: int = 100)

Adds a publisher.

Args:

class_type (Any): Class type of any ROS topic message type. topic (str): The ROS topic name queue_size (int, optional): Queue size. Defaults to 100.

Returns:

Publisher: The created publisher instance.

jsonfy(data: Any, metadata: list = None, tags: list = None) str

Formats a json object. The keys ‘stamp’, ‘frame_id’ and ‘tags’ are auto filled with the node name and the creation timestamp. The used data must be JSON compatible. The fields ‘metadata’ or ‘tags’ can be overwritten, if both are provided ‘metadata’ overwrites ‘tags’.

Example of the produced JSON:

{
    "metadata": [
        {"key": "stamp", "value": 1432343.034742467},
        {"key": "frame_id", "value": "a frame ID"},
        {"key": "tags", "value": ["tagname1", "another tag"]}
        <additional key/value entries ...>
    ],
    "data": <any kind of data>
}
Args:

data (Any): Data to add metadata (list, optional): If provided it superseeds default metadata. Defaults to None. tags (list, optional): If provided it overwrites default metadata[‘tags’]. If metadata is provide this paramater has no effect. Defaults to None.

Returns:

str: The resulting json String