|
| 1 | +from launch import LaunchDescription |
| 2 | +from launch.actions import DeclareLaunchArgument |
| 3 | +from launch.substitutions import LaunchConfiguration |
| 4 | +from launch_ros.actions import Node |
| 5 | +from launch.conditions import IfCondition |
| 6 | + |
| 7 | + |
| 8 | +def 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 | + |
| 40 | + 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, |
| 50 | + |
| 51 | + # Нода фронтальной камеры |
| 52 | + Node( |
| 53 | + package='usb_cam', |
| 54 | + executable='usb_cam_node_exe', |
| 55 | + name='front_camera_node', |
| 56 | + remappings=[ |
| 57 | + ('/image_raw', LaunchConfiguration("front_camera_topic")), |
| 58 | + ('/camera_info', LaunchConfiguration("front_camera_info_topic")), |
| 59 | + ], |
| 60 | + parameters=[ |
| 61 | + {'video_device': LaunchConfiguration("front_camera_path")}, |
| 62 | + {'camera_info_url': LaunchConfiguration( |
| 63 | + "front_camera_calibration_path")}, |
| 64 | + {'camera_name': 'front_camera'}, |
| 65 | + {'image_width': 640}, |
| 66 | + {'image_height': 480}, |
| 67 | + ], |
| 68 | + respawn=True, |
| 69 | + respawn_delay=1, |
| 70 | + ), |
| 71 | + # Нода нижней камеры (запускается при enable_bottom_camera==true) |
| 72 | + Node( |
| 73 | + package='usb_cam', |
| 74 | + executable='usb_cam_node_exe', |
| 75 | + name='bottom_camera_node', |
| 76 | + remappings=[ |
| 77 | + ('/image_raw', LaunchConfiguration("bottom_camera_topic")), |
| 78 | + ('/camera_info', LaunchConfiguration("bottom_camera_info_topic")), |
| 79 | + ], |
| 80 | + parameters=[ |
| 81 | + {'video_device': LaunchConfiguration("bottom_camera_path")}, |
| 82 | + {'camera_info_url': LaunchConfiguration( |
| 83 | + "bottom_camera_calibration_path")}, |
| 84 | + {'camera_name': 'bottom_camera'}, |
| 85 | + {'image_width': 640}, |
| 86 | + {'image_height': 480}, |
| 87 | + ], |
| 88 | + respawn=True, |
| 89 | + respawn_delay=1, |
| 90 | + condition=IfCondition(LaunchConfiguration('enable_bottom_camera')) |
| 91 | + ), |
| 92 | + ]) |
0 commit comments