|
| 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.actions import IncludeLaunchDescription |
| 8 | +from launch.launch_description_sources import PythonLaunchDescriptionSource |
| 9 | +from launch.substitutions import LaunchConfiguration |
| 10 | +from launch_ros.actions import Node |
| 11 | + |
| 12 | + |
| 13 | +def generate_launch_description(): |
| 14 | + |
| 15 | + calibration_config_dir = Path(get_package_share_directory('welt_cam')) / "configs" |
| 16 | + camera_calibration_path = calibration_config_dir / "bottom_camera.yaml" |
| 17 | + |
| 18 | + # bottom camera |
| 19 | + camera_topic_arg = DeclareLaunchArgument( |
| 20 | + "camera_bottom_topic_name", default_value='/stingray/topics/camera_bottom' |
| 21 | + ) |
| 22 | + camera_path_arg = DeclareLaunchArgument( |
| 23 | + "camera_bottom_path", default_value='/dev/video0' |
| 24 | + ) |
| 25 | + camera_calibration_path_arg = DeclareLaunchArgument( |
| 26 | + "camera_bottom_calibration_path", default_value=str(camera_calibration_path) |
| 27 | + ) |
| 28 | + box_topic_arg = DeclareLaunchArgument( |
| 29 | + "box_topic_name", default_value='/stingray/topics/marker_box' |
| 30 | + ) |
| 31 | + debug_arg = DeclareLaunchArgument( |
| 32 | + "debug", default_value='True' |
| 33 | + ) |
| 34 | + debug_topic_arg = DeclareLaunchArgument( |
| 35 | + "debug_image_name", default_value='/stingray/topics/marker_debug_image' |
| 36 | + ) |
| 37 | + kernel_arg = DeclareLaunchArgument( |
| 38 | + "kernel", default_value='5' |
| 39 | + ) |
| 40 | + sigma_arg = DeclareLaunchArgument( |
| 41 | + "sigma", default_value='3' |
| 42 | + ) |
| 43 | + closure_arg = DeclareLaunchArgument( |
| 44 | + "closure", default_value='10' |
| 45 | + ) |
| 46 | + light_arg = DeclareLaunchArgument( |
| 47 | + "light", default_value='0.6' |
| 48 | + ) |
| 49 | + grayness_arg = DeclareLaunchArgument( |
| 50 | + "grayness", default_value='0.1' |
| 51 | + ) |
| 52 | + |
| 53 | + # load ros config |
| 54 | + return LaunchDescription([ |
| 55 | + camera_topic_arg, |
| 56 | + camera_path_arg, |
| 57 | + camera_calibration_path_arg, |
| 58 | + box_topic_arg, |
| 59 | + debug_arg, |
| 60 | + debug_topic_arg, |
| 61 | + kernel_arg, |
| 62 | + sigma_arg, |
| 63 | + closure_arg, |
| 64 | + light_arg, |
| 65 | + grayness_arg, |
| 66 | + # bottom camera |
| 67 | + Node( |
| 68 | + package='marker_finder', |
| 69 | + executable='marker_detector', |
| 70 | + name='marker_finder_node', |
| 71 | + remappings=[ |
| 72 | + ('/image_raw', LaunchConfiguration("camera_bottom_topic")), |
| 73 | + ], |
| 74 | + parameters=[ |
| 75 | + {'video_device': LaunchConfiguration("camera_bottom_path")}, |
| 76 | + {'params-file': LaunchConfiguration("camera_bottom_calibration_path")}, |
| 77 | + # {'image_width': 640}, |
| 78 | + # {'image_height': 480}, |
| 79 | + # {'camera_name': 'camera'}, |
| 80 | + ], |
| 81 | + respawn=True, |
| 82 | + respawn_delay=1, |
| 83 | + ), |
| 84 | + ]) |
0 commit comments