1+ from pathlib import Path
2+
3+ from ament_index_python import get_package_share_directory
4+
5+ from launch import LaunchDescription
6+ from launch .actions import DeclareLaunchArgument
7+ from launch .substitutions import LaunchConfiguration
8+ from launch_ros .actions import Node
9+
10+ def generate_launch_description ():
11+
12+ try :
13+ calibration_config_dir = Path (get_package_share_directory ('stingray_core_sensors' )) / "configs"
14+ camera_calibration_path = calibration_config_dir / "camera.yaml"
15+ except Exception :
16+ camera_calibration_path = ""
17+
18+ camera_topic_arg_1 = DeclareLaunchArgument (
19+ "camera_topic_1" ,
20+ default_value = '/stingray_core/topics/camera_1'
21+ )
22+ camera_topic_arg_2 = DeclareLaunchArgument (
23+ "camera_topic_2" ,
24+ default_value = '/stingray_core/topics/camera_2'
25+ )
26+ camera_path_arg_1 = DeclareLaunchArgument (
27+ "camera_path_1" ,
28+ default_value = '/dev/video0'
29+ )
30+ camera_path_arg_2 = DeclareLaunchArgument (
31+ "camera_path_2" ,
32+ default_value = '/dev/video2'
33+ )
34+
35+
36+
37+ camera_calibration_path_arg = DeclareLaunchArgument (
38+ "camera_calibration_path" , default_value = str (camera_calibration_path )
39+ )
40+
41+
42+ camera_1_node = Node (
43+ package = 'usb_cam' ,
44+ executable = 'usb_cam_node_exe' ,
45+ name = 'video_display_node_1' ,
46+ output = 'screen' ,
47+ remappings = [
48+ ('/image_raw' , LaunchConfiguration ("camera_topic_1" )),
49+ ],
50+ parameters = [
51+ {'video_device' : LaunchConfiguration ("camera_path_1" )},
52+ {'params-file' : LaunchConfiguration ("camera_calibration_path" )},
53+ ],
54+ respawn = True ,
55+ respawn_delay = 1 ,
56+ )
57+
58+ camera_2_node = Node (
59+ package = 'usb_cam' ,
60+ executable = 'usb_cam_node_exe' ,
61+ name = 'video_display_node_2' ,
62+ output = 'screen' ,
63+ remappings = [
64+ ('/image_raw' , LaunchConfiguration ("camera_topic_2" )),
65+ ],
66+ parameters = [
67+ {'video_device' : LaunchConfiguration ("camera_path_2" )},
68+ {'params-file' : LaunchConfiguration ("camera_calibration_path" )},
69+ ],
70+ respawn = True ,
71+ respawn_delay = 1 ,
72+ )
73+
74+
75+ return LaunchDescription ([
76+ camera_topic_arg_1 ,
77+ camera_topic_arg_2 ,
78+ camera_path_arg_1 ,
79+ camera_path_arg_2 ,
80+ camera_calibration_path_arg ,
81+ camera_1_node ,
82+ camera_2_node ,
83+ ])
0 commit comments