diff --git a/tracing_interop/tr_types.py b/tracing_interop/tr_types.py index c799c68..3dd8201 100644 --- a/tracing_interop/tr_types.py +++ b/tracing_interop/tr_types.py @@ -13,7 +13,18 @@ Timestamp = namedtuple("Timestamp", ["timestamp"]) class Index(Generic[IdxItemType]): + """ + This class implements a sized, iterable collection that allows building indices on its content. + These indices are accessed by `index.by_()`. + 1-1, 1-n and n-m indices are supported. The indices are hash-, not range-based. + `IdxItemType` is expected to have a `timestamp` field by which this collection sorts its items. + """ def __init__(self, items: Iterable[IdxItemType], **idx_fields): + """ + Construct an index. + :param items: An iterable of items to add to the index. Items have to have a `timestamp` field + :param idx_fields: Keyword args of the shape ` = `. For each ``, an index (1 to 1 for `False`, 1 to n for `True`, n to m for `'n-to-m'` is generated which can be accessed by `index.by_('.") @@ -85,6 +126,11 @@ class Index(Generic[IdxItemType]): @dataclass class TrContext: + """ + Contains all data that is needed to represent a tracing session. + The contained data is postprocessed, interlinked and indexed after being retrieved from a ros2_tracing `Ros2Handler`. + """ + nodes: Index['TrNode'] publishers: Index['TrPublisher'] subscriptions: Index['TrSubscription'] @@ -99,6 +145,10 @@ class TrContext: _uuid: UUID def __init__(self, handler: Ros2Handler): + """ + Build the context from a `Ros2Handler` instance. + :param handler: The `Ros2Handler` instance to build the context from + """ print("[TrContext] Processing ROS 2 objects from traces...") self.nodes = Index(df_to_type_list(handler.data.nodes, TrNode, _c=self), @@ -149,6 +199,9 @@ class TrContext: @dataclass class TrNode: + """ + The representation of a ROS 2 node in the tracing context. + """ id: int timestamp: int tid: int @@ -184,6 +237,9 @@ class TrNode: @dataclass class TrPublisher: + """ + The representation of a ROS 2 publisher in the tracing context. + """ id: int timestamp: int node_handle: int @@ -217,6 +273,9 @@ class TrPublisher: @dataclass class TrSubscription: + """ + The representation of a ROS 2 subscription in the tracing context. + """ id: int timestamp: int node_handle: int @@ -250,6 +309,9 @@ class TrSubscription: @dataclass class TrTimer: + """ + The representation of a ROS 2 timer in the tracing context. + """ id: int timestamp: int period: int @@ -276,6 +338,9 @@ class TrTimer: @dataclass class TrTimerNodeLink: + """ + The relation connecting timers to nodes in ROS 2 tracing data. + """ id: int timestamp: int node_handle: int @@ -289,6 +354,9 @@ class TrTimerNodeLink: @dataclass class TrSubscriptionObject: + """ + The relation connecting subscriptions to callback objects to nodes in ROS 2 tracing data. + """ id: int timestamp: int subscription_handle: int @@ -311,6 +379,9 @@ class TrSubscriptionObject: @dataclass class TrCallbackObject: + """ + The relation connecting callback instances to subscriptions/timers/etc. in ROS 2 tracing data. + """ id: int # (reference) = subscription_object.id | timer.id | .... timestamp: int callback_object: int @@ -343,6 +414,9 @@ class TrCallbackObject: @dataclass class TrPublishInstance: + """ + A publication of a message in ROS 2 tracing data. + """ publisher_handle: int timestamp: float message: int @@ -361,6 +435,9 @@ class TrPublishInstance: @dataclass class TrCallbackInstance: + """ + An invocation of a callback (from a subscription or timer) in ROS 2 tracing data. + """ callback_object: int timestamp: float duration: float @@ -388,6 +465,11 @@ class TrCallbackInstance: @dataclass class TrCallbackSymbol: + """ + The C++ symbol corresponding to a callback in ROS 2 tracing data. + This is typically a very convoluted name with lots of C++ wrappers and almost no symbols or identifiers preserved. + Use `repr(matching.subscriptions.sanitize(tr_callback_symbol.symbol))` to get a readable name. + """ id: int # callback_object timestamp: int symbol: str @@ -410,6 +492,9 @@ class TrCallbackSymbol: @dataclass class TrTopic: + """ + The representation of a ROS 2 topic, linking publishers and subscriptions. + """ name: str _c: TrContext = field(repr=False) timestamp: int = 0