-
Notifications
You must be signed in to change notification settings - Fork 1
RGBD vs Stereo SLAM using realsense
-
RGBD SLAM with IR emitter ON (
SetParameter(name='depth_module.emitter_enabled', value=1)) performs well in indoor, textureless, short-range (IR range is typically 3-5m), in slow motion systems. RGB camera uses a Rolling Shutter which records the image line-by-line. If your robot turns fast, bumps over rough terrain, or is mounted on a vibrating drone, the RGB image suffers from the "jello effect" (wobbly, warped lines). This spatial distortion completely breaks feature tracking. Rtabmap launch file](https://github.com/introlab/rtabmap_ros/blob/ros2/rtabmap_examples/launch/realsense_d400.launch.py) -
Stereo SLAM with IR emitter OFF performs well in outdoors, fast motion (drones), large distances. Infrared cameras use a Global Shutter, meaning they capture the entire frame at the exact same microsecond.
-
Realsense camera can be launched as a node or as a launch file as shown below
realsense_camera_node = Node(
name='camera',
namespace='',
package='realsense2_camera',
executable='realsense2_camera_node',
parameters=[{
'enable_infra1': False,
'enable_infra2': False,
'enable_color': True,
'enable_depth': True,
'align_depth.enable': True,
'enable_sync': True,
'depth_module.emitter_enabled': 1, # <-- 1 = IR enabled, 0 = IR disabled
'depth_module.depth_profile': '640,360,60',
'rgb_camera.color_profile': '640,360,60',
'depth_module.enable_auto_exposure': True,
'rgb_camera.enable_auto_exposure': True,
'enable_gyro': False,
'enable_accel': False,
# Disable filters that add latency
'decimation_filter.enable': False,
'spatial_filter.enable': False,
'temporal_filter.enable': False,
'hole_filling_filter.enable': False,
}],
)
import os
from launch import LaunchDescription
from launch.substitutions import Command
from launch_ros.actions import Node, SetParameter
from launch.actions import IncludeLaunchDescription
from ament_index_python import get_package_share_directory
from launch_ros.parameter_descriptions import ParameterValue
from ament_index_python.packages import get_package_share_path
from launch.launch_description_sources import PythonLaunchDescriptionSource
def generate_launch_description():
ld = LaunchDescription()
robot_description = ParameterValue(
Command(['xacro ', str(get_package_share_path('realsense2_description') / 'urdf/test_d435_camera.urdf.xacro')]),
value_type=str
)
set_param = SetParameter(name='depth_module.emitter_enabled', value=1)
ld.add_action(set_param)
include_rs_cam = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('realsense2_camera'), 'launch/rs_launch.py')),
launch_arguments={
"depth_module.depth_profile": "640x480x30",
"depth_module.infra_profile": "640x480x30",
"rgb_camera.color_profile": "640x480x30",
"enable_color": "true",
"enable_depth": "true",
"enable_gyro": "true",
"enable_accel":"true",
"enable_sync": "true",
# "enable_infra1": "true",
# "enable_infra2": "true",
"unite_imu_method": "2",
"align_depth.enable": "true",
"camera_namespace": ""
# "pointcloud.enable": "True",
}.items()
)
ld.add_action(include_rs_cam)
node_cam_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
parameters=[
{'robot_description': robot_description}]
)
ld.add_action(node_cam_state_publisher)
return ld
realsense_camera_node = Node(
name='camera',
namespace='',
package='realsense2_camera',
executable='realsense2_camera_node',
parameters=[{
'enable_infra1': True,
'enable_infra2': True,
'enable_color': False,
'enable_depth': False,
'depth_module.emitter_enabled': 0,
'depth_module.infra_profile': '640,360,60',
'depth_module.profile': '640,360,60', # For backwards compatibility
'enable_gyro': True,
'enable_accel': True,
'gyro_fps': 200,
'accel_fps': 200, # set to 250 for rs d435i
'unite_imu_method': 2
}],
)
set_param = SetParameter(name='depth_module.emitter_enabled', value=0)
ld.add_action(set_param)
include_rs_cam = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('realsense2_camera'), 'launch/rs_launch.py')),
launch_arguments={
"depth_module.depth_profile": "640x480x30",
"depth_module.infra_profile": "640x480x30",
"rgb_camera.color_profile": "640x480x30",
"enable_color": "true", ## (1)Reason for this is explained below
"enable_depth": "true",
"enable_gyro": "true",
"enable_accel":"true",
"enable_sync": "true",
"enable_infra1": "true",
"enable_infra2": "true",
"unite_imu_method": "2",
"align_depth.enable": "true",
"camera_namespace": ""
# "pointcloud.enable": "True",
}.items()
)
ld.add_action(include_rs_cam)
The color is enabled for stereo mode because the Rtabmap slam can still use the color and depth images to come up with a colorised pointcloud from the stereo odometry.
When IR emitter is ON, a distinct dot pattern is projected by the camera. Since this projector is attached to the camera, every consecutive frames will have this pattern on it making the camera feel that it is not moving.