Files
rtabmap_ros/rtabmap_demos/launch/find_object_demo.launch.py
T
matlabbe 82f0754bf7 rtabmap_demos tests and docs (#1462)
* rtabmap_demos tests and docs

* added bag testing

* added rtabmap_examples launch tests

* updating demo bag download paths

* added netherdrone demo

* Fixed rgb-only callback with lidar rejected.  Updated lidar params

* Added back OrbitOriented rviz view to ros2, with optional octomap wll clipping

* fixing ci

* lidar demo added intermediate_nodes option

* added netherdrone as demo test

* running rtabmap_demos tests on ci

* added rtabmap_launch tests, fixed ground_truth_base_frame_id usage

* ficing rolling

* updating demo test harnest

* densify golden trajectories to avoid tf missing

* fixing tf steps

* updated min icp ratio for netherdrone demo

* fixing image_transport arg->params

* export pose opt=0

* lets process all frames

* updated netherdrone golden

* fixing publishers queue size just for tests

* added playdback demo doc

* Adding more logs to debug ci

* Fixing QOS for CI to reliable, added find-object demo test

* name threads

* fixing camera info expected transient on lyrical/rolling. Fixing find_object not appearing idle

* 30 Hz polling backward comp

* fixing test tf sim lock

* fixing lyrical qos bag parsing

* faster replay

* lockstep

* fixing clock deadlock

* Added test on shutdown

* updated netherdrone golden poses

* Extended stereo outdoor test

* updated shutdown test

* updated test

* multi-thread flaky test

* adding backtrace when test fails

* increased closure slack for netherdrone

* g2o gauss newton on stereo

* adjusted maximum optimizer iterations

* updated default iterations

* Added netherdrone in list of demos
2026-10-10 12:23:49 -07:00

147 lines
6.6 KiB
Python

# Requirements:
# find_object_2d package installed
# Download rosbag:
# * demo_find_object_bag.zip: https://github.com/introlab/rtabmap_ros/releases/download/0.23.13/demo_find_object_bag.zip
#
# Example:
#
# SLAM:
# $ ros2 launch rtabmap_demos find_object_demo.launch.py
#
# Rosbag:
# $ ros2 bag play demo_find_object_bag --clock
#
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch.conditions import IfCondition, UnlessCondition
from launch_ros.actions import Node
from launch_ros.actions import SetParameter
import os
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
localization = LaunchConfiguration('localization')
parameters={
'frame_id':'base_footprint',
'odom_frame_id':'odom',
'odom_tf_linear_variance':0.001,
'odom_tf_angular_variance':0.001,
'subscribe_rgbd':True,
'subscribe_scan':True,
'approx_sync':True,
'sync_queue_size': 10,
# RTAB-Map's internal parameters should be strings
'RGBD/NeighborLinkRefining': 'true', # Do odometry correction with consecutive laser scans
'Reg/Strategy': '1', # 0=Visual, 1=ICP, 2=Visual+ICP
'Reg/Force3DoF': 'true', # 2D SLAM
# The objects find_object_2d detects become landmarks (see find_object_to_landmarks.py,
# which sets their covariance from these, as rtabmap does for its own markers).
# Range and bearing only (GTSAM): the objects' orientation is the least reliable
# part of find_object_2d's estimate. Linear: the range variance (m^2), angular:
# the bearing variance (rad^2).
'Marker/VarianceLinear': '0.001',
'Marker/VarianceAngular': '0.01',
'Marker/VarianceOrientationIgnored': 'true',
'Optimizer/Strategy': '2', # GTSAM
}
remappings=[
('rgb/image', '/camera/data_throttled_image'),
('depth/image', '/camera/data_throttled_image_depth'),
('rgb/camera_info', '/camera/data_throttled_camera_info'),
('scan', '/base_scan')]
config_rviz = os.path.join(
get_package_share_directory('rtabmap_demos'), 'config', 'demo_robot_mapping.rviz'
)
config_find_object = os.path.join(
get_package_share_directory('rtabmap_demos'), 'config', 'find_object.ini'
)
data_find_object = os.path.join(
get_package_share_directory('rtabmap_demos'), 'data', 'books'
)
return LaunchDescription([
# Launch arguments
DeclareLaunchArgument('rtabmap_viz', default_value='false', description='Launch RTAB-Map UI (optional).'),
DeclareLaunchArgument('rviz', default_value='true', description='Launch RVIZ (optional).'),
DeclareLaunchArgument('find_object_gui', default_value='true', description='Show the Find-Object window (false: headless).'),
DeclareLaunchArgument('localization', default_value='false', description='Launch in localization mode.'),
DeclareLaunchArgument('rviz_cfg', default_value=config_rviz, description='Configuration path of rviz2.'),
SetParameter(name='use_sim_time', value=True),
# Nodes to launch
# Uncompress images for find_object
Node(
package='image_transport', executable='republish', name='republish_rgb', output='screen',
# The transports: as arguments up to humble, as parameters from jazzy.
arguments=['compressed', 'raw'],
parameters=[{'in_transport': 'compressed', 'out_transport': 'raw'}],
remappings=[('in/compressed', '/camera/data_throttled_image/compressed'),
('out', '/camera/data_throttled_image')]),
Node(
package='image_transport', executable='republish', name='republish_depth', output='screen',
# The transports: as arguments up to humble, as parameters from jazzy.
arguments=['compressedDepth', 'raw'],
parameters=[{'in_transport': 'compressedDepth', 'out_transport': 'raw'}],
remappings=[('in/compressedDepth', '/camera/data_throttled_image_depth/compressedDepth'),
('out', '/camera/data_throttled_image_depth')]),
Node(
package='rtabmap_sync', executable='rgbd_sync', output='screen',
parameters=[parameters,
{'approx_sync_max_interval': 0.02}],
remappings=remappings),
# SLAM mode:
Node(
condition=UnlessCondition(localization),
package='rtabmap_slam', executable='rtabmap', output='screen',
parameters=[parameters],
remappings=remappings,
arguments=['-d']), # This will delete the previous database (~/.ros/rtabmap.db)
# Localization mode:
Node(
condition=IfCondition(localization),
package='rtabmap_slam', executable='rtabmap', output='screen',
parameters=[parameters,
{'Mem/IncrementalMemory':'False',
'Mem/InitWMWithAllNodes':'True'}],
remappings=remappings),
# Visualization:
Node(
package='rtabmap_viz', executable='rtabmap_viz', output='screen',
condition=IfCondition(LaunchConfiguration("rtabmap_viz")),
parameters=[parameters],
remappings=remappings),
Node(
package='rviz2', executable='rviz2', name="rviz2", output='screen',
condition=IfCondition(LaunchConfiguration("rviz")),
arguments=[["-d"], [LaunchConfiguration("rviz_cfg")]]),
# Find-Object
Node(
package='find_object_2d', executable='find_object_2d', output='screen',
parameters=[{'gui': LaunchConfiguration('find_object_gui'),
'subscribe_depth': True,
'settings_path': config_find_object,
'objects_path': data_find_object}],
remappings=[('rgb/image_rect_color', '/camera/data_throttled_image'),
('depth_registered/image_raw', '/camera/data_throttled_image_depth'),
('depth_registered/camera_info', '/camera/data_throttled_camera_info')]),
# Its detections as landmarks for rtabmap (landmark_detections)
Node(
package='rtabmap_demos', executable='find_object_to_landmarks.py', output='screen',
parameters=[parameters]),
])