Add handling method for new tracepoint and update datra model

This commit is contained in:
Christophe Bedard 2019-11-17 10:12:33 -08:00
parent d29d54267d
commit 19e07b7875
2 changed files with 31 additions and 10 deletions

View file

@ -56,6 +56,10 @@ class RosDataModel(DataModel):
'topic_name', 'topic_name',
'depth']) 'depth'])
self.subscriptions.set_index(['subscription_handle'], inplace=True, drop=True) self.subscriptions.set_index(['subscription_handle'], inplace=True, drop=True)
self.subscriptions_objects = pd.DataFrame(columns=['subscription',
'timestamp',
'subscription_handle'])
self.subscriptions_objects.set_index(['subscription'], inplace=True, drop=True)
self.services = pd.DataFrame(columns=['service_handle', self.services = pd.DataFrame(columns=['service_handle',
'timestamp', 'timestamp',
'node_handle', 'node_handle',
@ -74,10 +78,10 @@ class RosDataModel(DataModel):
'tid']) 'tid'])
self.timers.set_index(['timer_handle'], inplace=True, drop=True) self.timers.set_index(['timer_handle'], inplace=True, drop=True)
self.callback_objects = pd.DataFrame(columns=['handle', self.callback_objects = pd.DataFrame(columns=['reference',
'timestamp', 'timestamp',
'callback_object']) 'callback_object'])
self.callback_objects.set_index(['handle'], inplace=True, drop=True) self.callback_objects.set_index(['reference'], inplace=True, drop=True)
self.callback_symbols = pd.DataFrame(columns=['callback_object', self.callback_symbols = pd.DataFrame(columns=['callback_object',
'timestamp', 'timestamp',
'symbol']) 'symbol'])
@ -104,11 +108,16 @@ class RosDataModel(DataModel):
) -> None: ) -> None:
self.publishers.loc[handle] = [timestamp, node_handle, rmw_handle, topic_name, depth] self.publishers.loc[handle] = [timestamp, node_handle, rmw_handle, topic_name, depth]
def add_subscription( def add_rcl_subscription(
self, handle, timestamp, node_handle, rmw_handle, topic_name, depth self, handle, timestamp, node_handle, rmw_handle, topic_name, depth
) -> None: ) -> None:
self.subscriptions.loc[handle] = [timestamp, node_handle, rmw_handle, topic_name, depth] self.subscriptions.loc[handle] = [timestamp, node_handle, rmw_handle, topic_name, depth]
def add_rclcpp_subscription(
self, subscription_pointer, timestamp, subscription_handle
) -> None:
self.subscriptions_objects[subscription_pointer] = [timestamp, subscription_handle]
def add_service( def add_service(
self, handle, timestamp, node_handle, rmw_handle, service_name self, handle, timestamp, node_handle, rmw_handle, service_name
) -> None: ) -> None:
@ -125,9 +134,9 @@ class RosDataModel(DataModel):
self.timers.loc[handle] = [timestamp, period, tid] self.timers.loc[handle] = [timestamp, period, tid]
def add_callback_object( def add_callback_object(
self, handle, timestamp, callback_object self, reference, timestamp, callback_object
) -> None: ) -> None:
self.callback_objects.loc[handle] = [timestamp, callback_object] self.callback_objects.loc[reference] = [timestamp, callback_object]
def add_callback_symbol( def add_callback_symbol(
self, callback_object, timestamp, symbol self, callback_object, timestamp, symbol
@ -156,6 +165,8 @@ class RosDataModel(DataModel):
print() print()
print(f'Subscriptions:\n{self.subscriptions.to_string()}') print(f'Subscriptions:\n{self.subscriptions.to_string()}')
print() print()
print(f'Subscription objects:\n{self.subscriptions_objects.to_string()}')
print()
print(f'Services:\n{self.services.to_string()}') print(f'Services:\n{self.services.to_string()}')
print() print()
print(f'Clients:\n{self.clients.to_string()}') print(f'Clients:\n{self.clients.to_string()}')

View file

@ -43,7 +43,9 @@ class Ros2Handler(EventHandler):
'ros2:rcl_publisher_init': 'ros2:rcl_publisher_init':
self._handle_rcl_publisher_init, self._handle_rcl_publisher_init,
'ros2:rcl_subscription_init': 'ros2:rcl_subscription_init':
self._handle_subscription_init, self._handle_rcl_subscription_init,
'ros2:rclcpp_subscription_init':
self._handle_rclcpp_subscription_init,
'ros2:rclcpp_subscription_callback_added': 'ros2:rclcpp_subscription_callback_added':
self._handle_rclcpp_subscription_callback_added, self._handle_rclcpp_subscription_callback_added,
'ros2:rcl_service_init': 'ros2:rcl_service_init':
@ -108,7 +110,7 @@ class Ros2Handler(EventHandler):
depth = get_field(event, 'queue_depth') depth = get_field(event, 'queue_depth')
self.data.add_publisher(handle, timestamp, node_handle, rmw_handle, topic_name, depth) self.data.add_publisher(handle, timestamp, node_handle, rmw_handle, topic_name, depth)
def _handle_subscription_init( def _handle_rcl_subscription_init(
self, event: Dict, metadata: EventMetadata self, event: Dict, metadata: EventMetadata
) -> None: ) -> None:
handle = get_field(event, 'subscription_handle') handle = get_field(event, 'subscription_handle')
@ -117,15 +119,23 @@ class Ros2Handler(EventHandler):
rmw_handle = get_field(event, 'rmw_subscription_handle') rmw_handle = get_field(event, 'rmw_subscription_handle')
topic_name = get_field(event, 'topic_name') topic_name = get_field(event, 'topic_name')
depth = get_field(event, 'queue_depth') depth = get_field(event, 'queue_depth')
self.data.add_subscription(handle, timestamp, node_handle, rmw_handle, topic_name, depth) self.data.add_rcl_subscription(handle, timestamp, node_handle, rmw_handle, topic_name, depth)
def _handle_rclcpp_subscription_init(
self, event: Dict, metadata: EventMetadata,
) -> None:
subscription_pointer = get_field(event, 'subscription')
timestamp = metadata.timestamp
handle = get_field(event, 'subscription_handle')
self.data.add_rclcpp_subscription(subscription_pointer, timestamp, handle)
def _handle_rclcpp_subscription_callback_added( def _handle_rclcpp_subscription_callback_added(
self, event: Dict, metadata: EventMetadata self, event: Dict, metadata: EventMetadata
) -> None: ) -> None:
handle = get_field(event, 'subscription_handle') subscription_pointer = get_field(event, 'subscription')
timestamp = metadata.timestamp timestamp = metadata.timestamp
callback_object = get_field(event, 'callback') callback_object = get_field(event, 'callback')
self.data.add_callback_object(handle, timestamp, callback_object) self.data.add_callback_object(subscription_pointer, timestamp, callback_object)
def _handle_rcl_service_init( def _handle_rcl_service_init(
self, event: Dict, metadata: EventMetadata self, event: Dict, metadata: EventMetadata