1+ from matplotlib import image
2+ import launch
3+ import launch_ros .actions
4+ from launch .actions import DeclareLaunchArgument
5+ from ament_index_python .packages import get_package_share_directory
6+ from launch .launch_description_sources import PythonLaunchDescriptionSource
7+ from launch .substitutions import LaunchConfiguration
8+
9+ from urllib .request import urlretrieve
10+ import os
11+
12+ def generate_launch_description ():
13+ yolox_ros_share_dir = get_package_share_directory ('yolox_ros_py' )
14+
15+ dog_path = os .path .join (yolox_ros_share_dir , "./" , "dog.jpg" )
16+ url = "https://raw.githubusercontent.com/pjreddie/darknet/master/data/dog.jpg"
17+ if not os .path .exists (dog_path ):
18+ os .system ("wget {} -O {}" .format (url , dog_path ))
19+
20+
21+ image_path = LaunchConfiguration ('image_path' , default = dog_path )
22+ image_path_arg = DeclareLaunchArgument (
23+ 'image_path' ,
24+ default_value = dog_path ,
25+ description = 'Image path'
26+ )
27+
28+ image_pub = launch_ros .actions .Node (
29+ package = 'image_publisher' ,
30+ executable = 'image_publisher_node' ,
31+ name = 'image_publisher' ,
32+ arguments = [image_path ],
33+ )
34+ yolox_onnx = launch_ros .actions .Node (
35+ package = "yolox_ros_py" , executable = "yolox_onnx" ,output = "screen" ,
36+ parameters = [
37+ {"input_shape/width" : 416 },
38+ {"input_shape/height" : 416 },
39+
40+ {"with_p6" : False },
41+ {"model_path" : yolox_ros_share_dir + "/yolox_nano.onnx" },
42+ {"conf" : 0.3 },
43+ ],
44+ )
45+
46+ rqt_graph = launch_ros .actions .Node (
47+ package = "rqt_graph" , executable = "rqt_graph" ,
48+ )
49+
50+ return launch .LaunchDescription ([
51+ image_path_arg ,
52+ image_pub ,
53+ yolox_onnx ,
54+ # rqt_graph
55+ ])
0 commit comments