import os from launch import LaunchDescription from launch_ros.actions import Node from launch.actions import DeclareLaunchArgument def generate_launch_description(): # Parâmetros comuns para Simulação use_sim_time = {'use_sim_time': True} # 1. Sincronizador RGB-D sync_node = Node( package='rtabmap_sync', executable='rgbd_sync', name='rgbd_sync', parameters=[{ 'approx_sync': True, 'approx_sync_max_interval': 0.125, 'queue_size': 10, **use_sim_time }], remappings=[ ('rgb/image', '/camera_front/rgb'), ('depth/image', '/camera_front/depth'), ('rgb/camera_info', '/camera_front/camera_info'), ('rgbd_image', '/camera_front/rgbd_image') ], output='screen' ) # 2. Visual Odometry Node # This node computes odometry from the RGB-D stream odom_node = Node( package='rtabmap_odom', executable='rgbd_odometry', name='rgbd_odometry', output='screen', parameters=[{ 'frame_id': 'base_footprint', 'odom_frame_id': 'odom', 'publish_tf': False, 'subscribe_rgbd': True, 'queue_size': 10, 'wait_for_transform': 0.2, # 'wait_imu_to_init': True, **use_sim_time, 'Vis/FeatureType': '2', 'Vis/RoiRatios': '0.0, 0.0, 0.0, 0.05', 'Odom/ResetCountdown': '1', # Automatically reset odom when lost (prevents total freeze) 'Odom/Strategy': '0', # 0=Frame-to-Map (more stable), 1=Frame-to-Frame 'Vis/MinInliers': '10', # Minimum features to accept a transformation 'Vis/MaxFeatures': '1000', # Increase the search space for features }], remappings=[ ('rgbd_image', '/camera_front/rgbd_image'), ('odom', '/rtabmap_odom') ] ) # 3. Nó Principal do RTAB-Map (SLAM) rtabmap_node = Node( package='rtabmap_slam', executable='rtabmap', name='rtabmap', output='screen', parameters=[{ 'subscribe_rgbd': True, 'subscribe_depth': False, 'subscribe_rgb': False, 'frame_id': 'base_footprint', 'map_frame_id': 'map', 'publish_tf': False, # RTAB-Map publishes map -> odom 'odom_frame_id': 'odom', 'Reg/Strategy': '0', # 0=Visual, 1=ICP, 2=Visual+ICP 'RGBD/ProximityBySpace': 'true', 'queue_size': 10, **use_sim_time, 'Grid/FromDepth': 'true', 'Vis/RoiRatios': '0.0, 0.0, 0.0, 0.2', 'Grid/DepthRoiRatios': '0.0, 0.0, 0.0, 0.2', }], remappings=[ ('rgbd_image', '/camera_front/rgbd_image'), ('odom', '/rtabmap_odom'), ], arguments=['--delete_db_on_start'] ) # 4. Visualização Opcional (RTAB-Map Viz) rtabmap_viz = Node( package='rtabmap_viz', executable='rtabmap_viz', name='rtabmap_viz', parameters=[{ 'subscribe_rgbd': True, 'frame_id': 'base_footprint', **use_sim_time }], remappings=[ ('rgbd_image', '/camera_front/rgbd_image') ], output='screen' ) return LaunchDescription([ sync_node, odom_node, rtabmap_node, # rtabmap_viz ])