|
| 1 | +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES |
| 2 | +# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# SPDX-License-Identifier: Apache-2.0 |
| 17 | +""" |
| 18 | +Live benchmarking Isaac ROS ArgusStereoNode. |
| 19 | +
|
| 20 | +The graph consists of the following: |
| 21 | +- Graph under Test: |
| 22 | + 1. ArgusStereoNode: publishes images |
| 23 | +
|
| 24 | +Required: |
| 25 | +- Packages: |
| 26 | + - isaac_ros_argus_camera |
| 27 | +""" |
| 28 | + |
| 29 | +from launch_ros.actions import ComposableNodeContainer |
| 30 | +from launch_ros.descriptions import ComposableNode |
| 31 | + |
| 32 | +from ros2_benchmark import ImageResolution |
| 33 | +from ros2_benchmark import BasicPerformanceCalculator, BenchmarkMode |
| 34 | +from ros2_benchmark import ROS2BenchmarkConfig, ROS2BenchmarkTest |
| 35 | +from ros2_benchmark import MonitorPerformanceCalculatorsInfo |
| 36 | + |
| 37 | +IMAGE_RESOLUTION = ImageResolution.HD |
| 38 | + |
| 39 | +def launch_setup(container_prefix, container_sigterm_timeout): |
| 40 | + """Generate launch description for live benchmarking Isaac ROS ArgusStereoNode.""" |
| 41 | + argus_node = ComposableNode( |
| 42 | + name='ArgusStereoNode', |
| 43 | + namespace=TestIsaacROSArgusStereoNode.generate_namespace(), |
| 44 | + package='isaac_ros_argus_camera', |
| 45 | + plugin='nvidia::isaac_ros::argus::ArgusStereoNode', |
| 46 | + parameters=[{ |
| 47 | + 'module_id': 5, |
| 48 | + }] |
| 49 | + ) |
| 50 | + |
| 51 | + left_image_monitor_node = ComposableNode( |
| 52 | + name='LeftImageMonitorNode', |
| 53 | + namespace=TestIsaacROSArgusStereoNode.generate_namespace(), |
| 54 | + package='isaac_ros_benchmark', |
| 55 | + plugin='isaac_ros_benchmark::NitrosMonitorNode', |
| 56 | + parameters=[{ |
| 57 | + 'monitor_index': 0, |
| 58 | + 'monitor_data_format': 'nitros_image_rgb8', |
| 59 | + 'use_nitros_type_monitor_sub': True, |
| 60 | + }], |
| 61 | + remappings=[('output', 'left/image_raw')] |
| 62 | + ) |
| 63 | + |
| 64 | + right_image_monitor_node = ComposableNode( |
| 65 | + name='RightImageMonitorNode', |
| 66 | + namespace=TestIsaacROSArgusStereoNode.generate_namespace(), |
| 67 | + package='isaac_ros_benchmark', |
| 68 | + plugin='isaac_ros_benchmark::NitrosMonitorNode', |
| 69 | + parameters=[{ |
| 70 | + 'monitor_index': 1, |
| 71 | + 'monitor_data_format': 'nitros_image_rgb8', |
| 72 | + 'use_nitros_type_monitor_sub': True, |
| 73 | + }], |
| 74 | + remappings=[('output', 'right/image_raw')] |
| 75 | + ) |
| 76 | + |
| 77 | + composable_node_container = ComposableNodeContainer( |
| 78 | + name='container', |
| 79 | + namespace=TestIsaacROSArgusStereoNode.generate_namespace(), |
| 80 | + package='rclcpp_components', |
| 81 | + executable='component_container_mt', |
| 82 | + prefix=container_prefix, |
| 83 | + sigterm_timeout=container_sigterm_timeout, |
| 84 | + composable_node_descriptions=[ |
| 85 | + argus_node, |
| 86 | + left_image_monitor_node, |
| 87 | + right_image_monitor_node, |
| 88 | + ], |
| 89 | + output='screen' |
| 90 | + ) |
| 91 | + |
| 92 | + return [composable_node_container] |
| 93 | + |
| 94 | +def generate_test_description(): |
| 95 | + return TestIsaacROSArgusStereoNode.generate_test_description_with_nsys(launch_setup) |
| 96 | + |
| 97 | + |
| 98 | +class TestIsaacROSArgusStereoNode(ROS2BenchmarkTest): |
| 99 | + """Live performance test for Isaac ROS ArgusStereoNode.""" |
| 100 | + |
| 101 | + # Custom configurations |
| 102 | + config = ROS2BenchmarkConfig( |
| 103 | + benchmark_name='Isaac ROS ArgusStereoNode Live Benchmark', |
| 104 | + benchmark_mode=BenchmarkMode.LIVE, |
| 105 | + benchmark_duration=5, |
| 106 | + test_iterations=5, |
| 107 | + collect_start_timestamps_from_monitors=True, |
| 108 | + custom_report_info={'data_resolution': IMAGE_RESOLUTION}, |
| 109 | + monitor_info_list=[ |
| 110 | + MonitorPerformanceCalculatorsInfo( |
| 111 | + 'start_monitoring0', |
| 112 | + [BasicPerformanceCalculator({ |
| 113 | + 'report_prefix': 'Argus Left Image', |
| 114 | + 'message_key_match': True |
| 115 | + })]), |
| 116 | + MonitorPerformanceCalculatorsInfo( |
| 117 | + 'start_monitoring1', |
| 118 | + [BasicPerformanceCalculator({ |
| 119 | + 'report_prefix': 'Argus Right Image', |
| 120 | + 'message_key_match': True |
| 121 | + })]) |
| 122 | + ] |
| 123 | + ) |
| 124 | + |
| 125 | + def test_benchmark(self): |
| 126 | + self.run_benchmark() |
0 commit comments