2022-11-27 18:01:16 -08:00
|
|
|
# Requirements:
|
|
|
|
|
# A realsense D435i
|
|
|
|
|
# Install realsense2 ros2 package (ros-$ROS_DISTRO-realsense2-camera)
|
|
|
|
|
# Example:
|
2023-02-26 18:05:08 -08:00
|
|
|
# $ ros2 launch rtabmap_examples realsense_d435i_infra.launch.py
|
2022-11-27 18:01:16 -08:00
|
|
|
|
2024-09-04 00:46:44 -07:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
|
|
2022-11-27 18:01:16 -08:00
|
|
|
from launch import LaunchDescription
|
2024-09-04 00:46:44 -07:00
|
|
|
from launch_ros.actions import Node, SetParameter
|
|
|
|
|
from launch.actions import IncludeLaunchDescription
|
|
|
|
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
2022-11-27 18:01:16 -08:00
|
|
|
|
|
|
|
|
def generate_launch_description():
|
|
|
|
|
parameters=[{
|
|
|
|
|
'frame_id':'camera_link',
|
|
|
|
|
'subscribe_depth':True,
|
2023-01-16 16:26:53 -08:00
|
|
|
'subscribe_odom_info':True,
|
2022-11-27 18:01:16 -08:00
|
|
|
'approx_sync':False,
|
|
|
|
|
'wait_imu_to_init':True}]
|
|
|
|
|
|
|
|
|
|
remappings=[
|
|
|
|
|
('imu', '/imu/data'),
|
|
|
|
|
('rgb/image', '/camera/infra1/image_rect_raw'),
|
|
|
|
|
('rgb/camera_info', '/camera/infra1/camera_info'),
|
|
|
|
|
('depth/image', '/camera/depth/image_rect_raw')]
|
|
|
|
|
|
|
|
|
|
return LaunchDescription([
|
|
|
|
|
|
2024-09-04 00:46:44 -07:00
|
|
|
#Hack to disable IR emitter
|
|
|
|
|
SetParameter(name='depth_module.emitter_enabled', value=0),
|
|
|
|
|
|
|
|
|
|
# Launch camera driver
|
|
|
|
|
IncludeLaunchDescription(
|
|
|
|
|
PythonLaunchDescriptionSource([os.path.join(
|
|
|
|
|
get_package_share_directory('realsense2_camera'), 'launch'),
|
|
|
|
|
'/rs_launch.py']),
|
2024-10-17 00:04:25 -04:00
|
|
|
launch_arguments={'camera_namespace': '',
|
|
|
|
|
'enable_gyro': 'true',
|
2024-09-04 00:46:44 -07:00
|
|
|
'enable_accel': 'true',
|
2024-10-17 00:04:25 -04:00
|
|
|
'unite_imu_method': '2',
|
2024-09-04 00:46:44 -07:00
|
|
|
'enable_infra1': 'true',
|
|
|
|
|
'enable_infra2': 'true',
|
|
|
|
|
'enable_sync': 'true'}.items(),
|
|
|
|
|
),
|
|
|
|
|
|
2022-11-27 18:01:16 -08:00
|
|
|
Node(
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_odom', executable='rgbd_odometry', output='screen',
|
2022-11-27 18:01:16 -08:00
|
|
|
parameters=parameters,
|
|
|
|
|
remappings=remappings),
|
|
|
|
|
|
|
|
|
|
Node(
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_slam', executable='rtabmap', output='screen',
|
2022-11-27 18:01:16 -08:00
|
|
|
parameters=parameters,
|
|
|
|
|
remappings=remappings,
|
|
|
|
|
arguments=['-d']),
|
|
|
|
|
|
|
|
|
|
Node(
|
2023-02-26 18:05:08 -08:00
|
|
|
package='rtabmap_viz', executable='rtabmap_viz', output='screen',
|
2022-11-27 18:01:16 -08:00
|
|
|
parameters=parameters,
|
|
|
|
|
remappings=remappings),
|
|
|
|
|
|
|
|
|
|
# Compute quaternion of the IMU
|
|
|
|
|
Node(
|
|
|
|
|
package='imu_filter_madgwick', executable='imu_filter_madgwick_node', output='screen',
|
|
|
|
|
parameters=[{'use_mag': False,
|
|
|
|
|
'world_frame':'enu',
|
|
|
|
|
'publish_tf':False}],
|
|
|
|
|
remappings=[('imu/data_raw', '/camera/imu')]),
|
|
|
|
|
|
2023-05-19 05:03:18 +02:00
|
|
|
# The IMU frame is missing in TF tree, add it:
|
2022-11-27 18:01:16 -08:00
|
|
|
Node(
|
|
|
|
|
package='tf2_ros', executable='static_transform_publisher', output='screen',
|
|
|
|
|
arguments=['0', '0', '0', '0', '0', '0', 'camera_gyro_optical_frame', 'camera_imu_optical_frame']),
|
|
|
|
|
])
|