1+ from pathlib import Path
2+
3+ from ament_index_python import get_package_share_directory
4+ from launch .launch_description_sources import PythonLaunchDescriptionSource
15from launch import LaunchDescription
26from launch .actions import DeclareLaunchArgument
37from launch .substitutions import LaunchConfiguration
48from launch_ros .actions import Node
59from launch .conditions import IfCondition
10+ from launch .actions import IncludeLaunchDescription
611
712
813def generate_launch_description ():
9- # Аргументы для фронтальной камеры
10- front_camera_topic_arg = DeclareLaunchArgument (
11- "front_camera_topic" , default_value = '/stingray/topics/camera/front'
12- )
13- front_camera_info_topic_arg = DeclareLaunchArgument (
14- "front_camera_info_topic" , default_value = '/stingray/topics/camera/front/camera_info'
15- )
16- front_camera_path_arg = DeclareLaunchArgument (
17- "front_camera_path" , default_value = '/dev/video0'
18- )
19- front_camera_calibration_path_arg = DeclareLaunchArgument (
20- "front_camera_calibration_path" , default_value = "package://welt_cam/configs/front_camera.yaml"
21- )
22- # Аргументы для нижней камеры
23- bottom_camera_topic_arg = DeclareLaunchArgument (
24- "bottom_camera_topic" , default_value = '/stingray/topics/camera/bottom'
25- )
26- bottom_camera_info_topic_arg = DeclareLaunchArgument (
27- "bottom_camera_info_topic" , default_value = '/stingray/topics/camera/bottom/camera_info'
28- )
29- bottom_camera_path_arg = DeclareLaunchArgument (
30- "bottom_camera_path" , default_value = '/dev/video4'
31- )
32- bottom_camera_calibration_path_arg = DeclareLaunchArgument (
33- "bottom_camera_calibration_path" , default_value = "package://welt_cam/configs/bottom_camera.yaml"
34- )
35- enable_bottom_camera_arg = DeclareLaunchArgument (
36- "enable_bottom_camera" , default_value = "true" ,
37- description = "Включить (true) или отключить (false) ноду нижней камеры"
38- )
39-
4014 return LaunchDescription ([
41- front_camera_topic_arg ,
42- front_camera_info_topic_arg ,
43- front_camera_path_arg ,
44- front_camera_calibration_path_arg ,
45- bottom_camera_topic_arg ,
46- bottom_camera_info_topic_arg ,
47- bottom_camera_path_arg ,
48- bottom_camera_calibration_path_arg ,
49- enable_bottom_camera_arg ,
15+ DeclareLaunchArgument ("enable_front_camera" ,
16+ default_value = "true" ,
17+ description = "Включить (true) или отключить (false) ноду нижней камеры" ),
18+ DeclareLaunchArgument ('front_camera_topic' ,
19+ default_value = '/stingray/topics/camera/front' ,
20+ description = 'Топик с изображениями для первой камеры' ),
21+ DeclareLaunchArgument ("front_camera_info_topic" ,
22+ default_value = '/stingray/topics/camera/front/camera_info' ),
23+ DeclareLaunchArgument ("front_camera_path" ,
24+ default_value = '/dev/video0' ),
25+ DeclareLaunchArgument ("front_camera_calibration_path" ,
26+ default_value = "package://sauvc_cam/configs/front_camera.yaml" ),
27+ DeclareLaunchArgument ('front_camera_output_width' ,
28+ default_value = '640' ,
29+ description = 'Ширина видео' ),
30+ DeclareLaunchArgument ('front_camera_output_height' ,
31+ default_value = '480' ,
32+ description = 'Высота видео' ),
33+ # bottom camera
34+ DeclareLaunchArgument ("enable_bottom_camera" ,
35+ default_value = "true" ,
36+ description = "Включить (true) или отключить (false) ноду нижней камеры" ),
37+ DeclareLaunchArgument ('bottom_camera_topic' ,
38+ default_value = '/stingray/topics/camera/bottom' ,
39+ description = 'Топик с изображениями для второй камеры' ),
40+ DeclareLaunchArgument ("bottom_camera_info_topic" ,
41+ default_value = '/stingray/topics/camera/bottom/camera_info' ),
42+ DeclareLaunchArgument ("bottom_camera_path" ,
43+ default_value = '/dev/video2' ),
44+ DeclareLaunchArgument ("bottom_camera_calibration_path" ,
45+ default_value = "package://sauvc_cam/configs/bottom_camera.yaml" ),
46+ DeclareLaunchArgument ('bottom_camera_output_width' ,
47+ default_value = '640' ,
48+ description = 'Ширина видео' ),
49+ DeclareLaunchArgument ('bottom_camera_output_height' ,
50+ default_value = '480' ,
51+ description = 'Высота видео' ),
52+ # recorder
53+ DeclareLaunchArgument ("enable_recording_front_camera" ,
54+ default_value = "true" ,
55+ description = "Включить (true) или отключить (false) ноду нижней камеры" ),
56+ DeclareLaunchArgument ("enable_recording_bottom_camera" ,
57+ default_value = "true" ,
58+ description = "Включить(true) или отключить(false) ноду нижней камеры" ),
59+ DeclareLaunchArgument ('output_fps' ,
60+ default_value = '15' ,
61+ description = 'Частота кадров видео' ),
62+ DeclareLaunchArgument ('output_format' ,
63+ default_value = 'h264' ,
64+ description = 'Формат видео (FourCC)' ),
65+ DeclareLaunchArgument ('record_dir' ,
66+ default_value = './records/' ,
67+ description = 'Путь к папке для сохранения записей' ),
68+
69+ IncludeLaunchDescription (
70+ PythonLaunchDescriptionSource (str (Path (
71+ get_package_share_directory ('stingray_launch' ), 'zbar.launch.py' ))),
72+ launch_arguments = {
73+ 'zbar_camera_topic' : LaunchConfiguration ("front_camera_topic" ),
74+ }.items (),
75+ ),
5076
5177 # Нода фронтальной камеры
5278 Node (
@@ -62,11 +88,14 @@ def generate_launch_description():
6288 {'camera_info_url' : LaunchConfiguration (
6389 "front_camera_calibration_path" )},
6490 {'camera_name' : 'front_camera' },
65- {'image_width' : 640 },
66- {'image_height' : 480 },
91+ {'image_width' : LaunchConfiguration (
92+ "front_camera_output_width" )},
93+ {'image_height' : LaunchConfiguration (
94+ "front_camera_output_height" )},
6795 ],
6896 respawn = True ,
6997 respawn_delay = 1 ,
98+ condition = IfCondition (LaunchConfiguration ('enable_front_camera' ))
7099 ),
71100 # Нода нижней камеры (запускается при enable_bottom_camera==true)
72101 Node (
@@ -82,11 +111,41 @@ def generate_launch_description():
82111 {'camera_info_url' : LaunchConfiguration (
83112 "bottom_camera_calibration_path" )},
84113 {'camera_name' : 'bottom_camera' },
85- {'image_width' : 640 },
86- {'image_height' : 480 },
114+ {'image_width' : LaunchConfiguration (
115+ "bottom_camera_output_width" )},
116+ {'image_height' : LaunchConfiguration (
117+ "bottom_camera_output_width" )},
87118 ],
88119 respawn = True ,
89120 respawn_delay = 1 ,
90121 condition = IfCondition (LaunchConfiguration ('enable_bottom_camera' ))
91122 ),
123+
124+ IncludeLaunchDescription (
125+ PythonLaunchDescriptionSource (str (Path (
126+ get_package_share_directory ('stingray_launch' ), 'recorder.launch.py' ))),
127+ launch_arguments = {
128+ 'source_topic' : LaunchConfiguration ('front_camera_topic' ),
129+ 'output_width' : LaunchConfiguration ('front_camera_output_width' ),
130+ 'output_height' : LaunchConfiguration ('front_camera_output_height' ),
131+ 'output_fps' : LaunchConfiguration ('output_fps' ),
132+ 'output_format' : LaunchConfiguration ('output_format' ),
133+ 'record_dir' : LaunchConfiguration ('record_dir' ),
134+ }.items (),
135+ condition = IfCondition (LaunchConfiguration ('enable_recording_front_camera' ))
136+ ),
137+
138+ IncludeLaunchDescription (
139+ PythonLaunchDescriptionSource (str (Path (
140+ get_package_share_directory ('stingray_launch' ), 'recorder.launch.py' ))),
141+ launch_arguments = {
142+ 'source_topic' : LaunchConfiguration ('bottom_camera_topic' ),
143+ 'output_width' : LaunchConfiguration ('bottom_camera_output_width' ),
144+ 'output_height' : LaunchConfiguration ('bottom_camera_output_height' ),
145+ 'output_fps' : LaunchConfiguration ('output_fps' ),
146+ 'output_format' : LaunchConfiguration ('output_format' ),
147+ 'record_dir' : LaunchConfiguration ('record_dir' ),
148+ }.items (),
149+ condition = IfCondition (LaunchConfiguration ('enable_recording_bottom_camera' ))
150+ ),
92151 ])
0 commit comments