Skip to content

Commit 01126ee

Browse files
committed
update launch
1 parent e6574d3 commit 01126ee

6 files changed

Lines changed: 482 additions & 512 deletions

File tree

Lines changed: 105 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
import os
2-
import sys
1+
# Copyright 2023 Ar-Ray-code
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
316
import launch
4-
import launch_ros.actions
517
from launch.actions import DeclareLaunchArgument
618
from launch.substitutions import LaunchConfiguration
719
from launch_ros.actions import ComposableNodeContainer
@@ -10,141 +22,135 @@
1022
def generate_launch_description():
1123
launch_args = [
1224
DeclareLaunchArgument(
13-
"video_device",
14-
default_value="/dev/video0",
15-
description="input video source"
25+
'video_device',
26+
default_value='/dev/video0',
27+
description='input video source'
1628
),
1729
DeclareLaunchArgument(
18-
"model_path",
19-
default_value="./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnx",
20-
description="yolox model path."
30+
'model_path',
31+
default_value='./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnx',
32+
description='yolox model path.'
2133
),
2234
DeclareLaunchArgument(
23-
"p6",
24-
default_value="false",
25-
description="with p6."
35+
'p6',
36+
default_value='false',
37+
description='with p6.'
2638
),
2739
DeclareLaunchArgument(
28-
"class_labels_path",
29-
default_value="''",
30-
description="if use custom model, set class name labels. "
40+
'class_labels_path',
41+
default_value='',
42+
description='if use custom model, set class name labels. '
3143
),
3244
DeclareLaunchArgument(
33-
"num_classes",
34-
default_value="80",
35-
description="num classes."
45+
'num_classes',
46+
default_value='80',
47+
description='num classes.'
3648
),
3749
DeclareLaunchArgument(
38-
"model_version",
39-
default_value="0.1.1rc0",
40-
description="yolox model version."
50+
'model_version',
51+
default_value='0.1.1rc0',
52+
description='yolox model version.'
4153
),
4254
DeclareLaunchArgument(
43-
"onnxruntime/use_cuda",
44-
default_value="true",
45-
description="onnxruntime use cuda."
55+
'onnxruntime/use_cuda',
56+
default_value='true',
57+
description='onnxruntime use cuda.'
4658
),
4759
DeclareLaunchArgument(
48-
"onnxruntime/device_id",
49-
default_value="0",
50-
description="onnxruntime gpu device id."
60+
'onnxruntime/device_id',
61+
default_value='0',
62+
description='onnxruntime gpu device id.'
5163
),
5264
DeclareLaunchArgument(
53-
"onnxruntime/use_parallel",
54-
default_value="false",
55-
description="if use_parallel is true, you can set inter_op_num_threads."
65+
'onnxruntime/use_parallel',
66+
default_value='false',
67+
description='if use_parallel is true, you can set inter_op_num_threads.'
5668
),
5769
DeclareLaunchArgument(
58-
"onnxruntime/inter_op_num_threads",
59-
default_value="1",
60-
description="control the number of threads used to parallelize the execution of the graph (across nodes)."
70+
'onnxruntime/inter_op_num_threads',
71+
default_value='1'
6172
),
6273
DeclareLaunchArgument(
63-
"onnxruntime/intra_op_num_threads",
64-
default_value="1",
65-
description="ontrols the number of threads to use to run the model."
74+
'onnxruntime/intra_op_num_threads',
75+
default_value='1',
76+
description='ontrols the number of threads to use to run the model.'
6677
),
6778
DeclareLaunchArgument(
68-
"conf",
69-
default_value="0.30",
70-
description="yolox confidence threshold."
79+
'conf',
80+
default_value='0.30',
81+
description='yolox confidence threshold.'
7182
),
7283
DeclareLaunchArgument(
73-
"nms",
74-
default_value="0.45",
75-
description="yolox nms threshold"
84+
'nms',
85+
default_value='0.45',
86+
description='yolox nms threshold'
7687
),
7788
DeclareLaunchArgument(
78-
"imshow_isshow",
79-
default_value="true",
80-
description=""
89+
'imshow_isshow',
90+
default_value='true',
91+
description=''
8192
),
8293
DeclareLaunchArgument(
83-
"src_image_topic_name",
84-
default_value="/image_raw",
85-
description="topic name for source image"
94+
'src_image_topic_name',
95+
default_value='/image_raw',
96+
description='topic name for source image'
8697
),
8798
DeclareLaunchArgument(
88-
"publish_image_topic_name",
89-
default_value="/yolox/image_raw",
90-
description="topic name for publishing image with bounding box drawn"
99+
'publish_image_topic_name',
100+
default_value='/yolox/image_raw',
101+
description='topic name for publishing image with bounding box drawn'
91102
),
92103
DeclareLaunchArgument(
93-
"publish_boundingbox_topic_name",
94-
default_value="/yolox/bounding_boxes",
95-
description="topic name for publishing bounding box message."
104+
'publish_boundingbox_topic_name',
105+
default_value='/yolox/bounding_boxes',
106+
description='topic name for publishing bounding box message.'
96107
),
97108
]
98109
container = ComposableNodeContainer(
99-
name='yolox_container',
100-
namespace='',
101-
package='rclcpp_components',
102-
executable='component_container',
103-
composable_node_descriptions=[
104-
ComposableNode(
105-
package='v4l2_camera',
106-
plugin='v4l2_camera::V4L2Camera',
107-
name='v4l2_camera',
108-
parameters=[{
109-
"video_device": LaunchConfiguration("video_device"),
110-
"image_size": [640,480]
111-
}]),
112-
ComposableNode(
113-
package='yolox_ros_cpp',
114-
plugin='yolox_ros_cpp::YoloXNode',
115-
name='yolox_ros_cpp',
116-
parameters=[{
117-
"model_path": LaunchConfiguration("model_path"),
118-
"p6": LaunchConfiguration("p6"),
119-
"class_labels_path": LaunchConfiguration("class_labels_path"),
120-
"num_classes": LaunchConfiguration("num_classes"),
121-
"model_type": "onnxruntime",
122-
"model_version": LaunchConfiguration("model_version"),
123-
"onnxruntime/use_cuda": LaunchConfiguration("onnxruntime/use_cuda"),
124-
"onnxruntime/device_id": LaunchConfiguration("onnxruntime/device_id"),
125-
"onnxruntime/use_parallel": LaunchConfiguration("onnxruntime/use_parallel"),
126-
"onnxruntime/inter_op_num_threads": LaunchConfiguration("onnxruntime/inter_op_num_threads"),
127-
"onnxruntime/intra_op_num_threads": LaunchConfiguration("onnxruntime/intra_op_num_threads"),
128-
"conf": LaunchConfiguration("conf"),
129-
"nms": LaunchConfiguration("nms"),
130-
"imshow_isshow": LaunchConfiguration("imshow_isshow"),
131-
"src_image_topic_name": LaunchConfiguration("src_image_topic_name"),
132-
"publish_image_topic_name": LaunchConfiguration("publish_image_topic_name"),
133-
"publish_boundingbox_topic_name": LaunchConfiguration("publish_boundingbox_topic_name"),
134-
}],
135-
),
136-
],
137-
output='screen',
138-
)
139-
140-
rqt = launch_ros.actions.Node(
141-
package="rqt_graph", executable="rqt_graph",
110+
name='yolox_container',
111+
namespace='',
112+
package='rclcpp_components',
113+
executable='component_container',
114+
composable_node_descriptions=[
115+
ComposableNode(
116+
package='v4l2_camera',
117+
plugin='v4l2_camera::V4L2Camera',
118+
name='v4l2_camera',
119+
parameters=[{
120+
'video_device': LaunchConfiguration('video_device'),
121+
'image_size': [640, 480]
122+
}]),
123+
ComposableNode(
124+
package='yolox_ros_cpp',
125+
plugin='yolox_ros_cpp::YoloXNode',
126+
name='yolox_ros_cpp',
127+
parameters=[{
128+
'model_path': LaunchConfiguration('model_path'),
129+
'p6': LaunchConfiguration('p6'),
130+
'class_labels_path': LaunchConfiguration('class_labels_path'),
131+
'num_classes': LaunchConfiguration('num_classes'),
132+
'model_type': 'onnxruntime',
133+
'model_version': LaunchConfiguration('model_version'),
134+
'onnxruntime/use_cuda': LaunchConfiguration('onnxruntime/use_cuda'),
135+
'onnxruntime/device_id': LaunchConfiguration('onnxruntime/device_id'),
136+
'onnxruntime/use_parallel': LaunchConfiguration('onnxruntime/use_parallel'),
137+
'onnxruntime/inter_op_num_threads': LaunchConfiguration('onnxruntime/inter_op_num_threads'),
138+
'onnxruntime/intra_op_num_threads': LaunchConfiguration('onnxruntime/intra_op_num_threads'),
139+
'conf': LaunchConfiguration('conf'),
140+
'nms': LaunchConfiguration('nms'),
141+
'imshow_isshow': LaunchConfiguration('imshow_isshow'),
142+
'src_image_topic_name': LaunchConfiguration('src_image_topic_name'),
143+
'publish_image_topic_name': LaunchConfiguration('publish_image_topic_name'),
144+
'publish_boundingbox_topic_name': LaunchConfiguration('publish_boundingbox_topic_name'),
145+
}],
146+
),
147+
],
148+
output='screen',
142149
)
143150

144151
return launch.LaunchDescription(
145152
launch_args +
146153
[
147-
container,
148-
# rqt_graph,
154+
container
149155
]
150156
)

0 commit comments

Comments
 (0)