rtabmap_ros icon indicating copy to clipboard operation
rtabmap_ros copied to clipboard

Coordinate frames error using d435i

Open KTsapCyric opened this issue 3 months ago • 3 comments

I have an issue with the d435i camera when enabling the IMU because when moving the UGV forward the y axis is decreasing and same for the x axis.

I did a test without the IMU with the d435i and d435f cameras and it is working correctly, +x forward and +y left.

What should i do?

KTsapCyric avatar Sep 24 '25 09:09 KTsapCyric

There should not be a big difference between using IMU or not for the relative motion. Can you show how do you filter the imu from the camera for rtabmap usage?

matlabbe avatar Sep 28 '25 18:09 matlabbe

I am using the launch file from the rtabmap_examples

# Requirements:
#   A realsense D435i
#   Install realsense2 ros2 package (ros-$ROS_DISTRO-realsense2-camera)
# Example:
#   $ ros2 launch rtabmap_examples realsense_d435i_color.launch.py

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch_ros.actions import Node, SetParameter
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    parameters=[{
          'frame_id':'camera_link',
          'subscribe_depth':True,
          'subscribe_odom_info':True,
          'approx_sync':False,
          'wait_imu_to_init':True}]

    remappings=[
          ('imu', '/imu/data'),
          ('rgb/image', '/camera/color/image_raw'),
          ('rgb/camera_info', '/camera/color/camera_info'),
          ('depth/image', '/camera/aligned_depth_to_color/image_raw')]

    return LaunchDescription([

        # Launch arguments
        DeclareLaunchArgument(
            'unite_imu_method', default_value='2',
            description='0-None, 1-copy, 2-linear_interpolation. Use unite_imu_method:="1" if imu topics stop being published.'),

        # Make sure IR emitter is enabled
        SetParameter(name='depth_module.emitter_enabled', value=1),

        # Launch camera driver
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource([os.path.join(
                get_package_share_directory('realsense2_camera'), 'launch'),
                '/rs_launch.py']),
                launch_arguments={'camera_namespace': '',
                                  'enable_gyro': 'true',
                                  'enable_accel': 'true',
                                  'unite_imu_method': LaunchConfiguration('unite_imu_method'),
                                  'align_depth.enable': 'true',
                                  'enable_sync': 'true',
                                  'rgb_camera.profile': '640x360x30'}.items(),
        ),

        Node(
            package='rtabmap_odom', executable='rgbd_odometry', output='screen',
            parameters=parameters,
            remappings=remappings),

        Node(
            package='rtabmap_slam', executable='rtabmap', output='screen',
            parameters=parameters,
            remappings=remappings,
            arguments=['-d']),

        Node(
            package='rtabmap_viz', executable='rtabmap_viz', output='screen',
            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')]),
    ])

Without the use of imu the results are correct, with the imu i assume there is a rotation in the madgwick filter?

KTsapCyric avatar Sep 28 '25 21:09 KTsapCyric

One thing I could see is that the IMU's static transform is wrong, though the realsense driver should give already a fairly accurate one. Can you record some data while moving forward and share it? (just with the realsense2 node started)

ros2 bag record --compression-mode file --compression-format zstd \
   /tf /tf_static /camera/imu \
   /camera/color/image_raw \
   /camera/color/camera_info \
   /camera/aligned_depth_to_color/image_raw

matlabbe avatar Sep 28 '25 22:09 matlabbe