File size: 3,583 Bytes
9869d0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
    ])