mapping-3d
読み取り中…
検索中…
一致する文字列を見つけられません
rtabmap_official.launch.py
[詳解]
2import os
3
4from ament_index_python.packages import get_package_share_directory
5from launch import LaunchDescription
6from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
7from launch.launch_description_sources import PythonLaunchDescriptionSource
8from launch.substitutions import LaunchConfiguration
9
11 # realsense2_camera のパッケージディレクトリを取得
12 realsense_share_dir = get_package_share_directory('realsense2_camera')
13
14 # rtabmap_launch のパッケージディレクトリを取得
15 # ROS 2 Humbleでは通常 rtabmap_launch に launch ファイルが含まれます
16 try:
17 rtabmap_share_dir = get_package_share_directory('rtabmap_launch')
18 except Exception:
19 rtabmap_share_dir = get_package_share_directory('rtabmap_ros')
20
21 # RealSense カメラの起動設定
22 realsense_launch = IncludeLaunchDescription(
23 PythonLaunchDescriptionSource(
24 os.path.join(realsense_share_dir, 'launch', 'rs_launch.py')
25 ),
26 launch_arguments={
27 'align_depth.enable': 'true', # デプス画像をカラー画像にアライメント
28 'pointcloud.enable': 'false', # カメラ側での点群生成を無効化(rtabmap側で生成するため)
29 'enable_gyro': 'true', # IMU対応カメラ(D435i等)のためのジャイロ有効化
30 'enable_accel': 'true', # 加速度計有効化
31 }.items()
32 )
33
34 # RTAB-Map の起動設定
35 rtabmap_launch_desc = IncludeLaunchDescription(
36 PythonLaunchDescriptionSource(
37 os.path.join(rtabmap_share_dir, 'launch', 'rtabmap.launch.py')
38 ),
39 launch_arguments={
40 'rtabmap_args': '--delete_db_on_start', # 起動時にデータベースを初期化
41 'rgb_topic': '/camera/camera/color/image_raw',
42 'depth_topic': '/camera/camera/aligned_depth_to_color/image_raw',
43 'camera_info_topic': '/camera/camera/color/camera_info',
44 'frame_id': 'camera_link',
45 'approx_sync': 'true', # 約同期を有効にする
46 'rtabmap_viz': 'true', # RTAB-Map可視化GUIを起動
47 'rviz': 'false', # rtabmap_vizと両方起動しないようにRVizは無効化
48 }.items()
49 )
50
51 ld = LaunchDescription()
52 ld.add_action(realsense_launch)
53 ld.add_action(rtabmap_launch_desc)
54
55 return ld