Using External FOG-IMU with ZED2i for Better EKF Accuracy – Frame Alignment Issue in robot_localization (ROS2)

To improve pose accuracy and reduce drift during rotation, I’m trying to replace the ZED2i’s built-in IMU with my own FOG-IMU (Fiber-Optic Gyroscope). I’m using ROS 2 (Humble) and the robot_localization package for sensor fusion with an Extended Kalman Filter (EKF). Here’s what I did:

  1. Set imu_fusion to false in common_stereo.yaml.
  2. Launched ZED node with: ros2 launch zed_wrapper zed_camera.launch.py camera_model:=zed2i
  3. Created a custom ROS2 node to publish my FOG-IMU data at /Fog_imu/imu_data.
  4. Launched EKF fusion node: ros2 launch ekf_fusion.launch.py
# ekf_fusion.launch.py
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        # Static transform: imu_link → base_link
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            name='imu_to_base',
            arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'imu_link'],
        ),

        # EKF node
        Node(
            package='robot_localization',
            executable='ekf_node',
            name='ekf_filter',
            output='screen',
            parameters=[{
                'use_sim_time': False,
                'frequency': 50.0,
                'sensor_timeout': 0.1,
                'two_d_mode': False,
                'publish_tf': True,
                'transform_tolerance': 0.1,
                'pose0': '/zed/zed_node/pose_with_covariance',  
                'pose0_config': [
                    True,  True,  True,   # X, Y, Z
                    False, False, False,   # roll, pitch, yaw
                    False, False, False,   # VX, VY, VZ
                    False, False, False,  # VRoll, VPitch, VYaw
                    False, False, False,   # AX, AY, AZ 
                ],
                'pose0_differential': False,
                'pose0_queue_size': 5,

                'imu0': '/Fog_imu/imu_data',
                'imu0_config': [
                    False, False, False,  # X, Y, Z
                    True,  True,  True,   # roll, pitch, yaw
                    False, False, False,  # VX, VY, VZ
                    True,  True,  True,   # VRoll, VPitch, VYaw
                    False, False, False,   # AX, AY, AZ
                ],
                'imu0_differential': False,
                'imu0_queue_size': 5,

                'odom0': '/zed/zed_node/odom',
                'odom0_config': [
                    False, False, False, 
                    False, False, False,
                    False, False, False,
                    False, False, False,
                    False, False, False
                ],
                'odom0_differential': False,
                'odom0_queue_size': 10
            }]
        )
    ])

  1. Monitored the output from /odometry/filtered.

Platform Specs:

  • Jetson Orin NX 8GB
  • ROS 2: Humble
  • ZED SDK: 5.0.1 (L4T 36.4)

:warning: Problem Encountered

I noticed that:

  • /zed/zed_node/pose_with_covariance has frame_id = "map"
  • /odometry/filtered has frame_id = "odom"

As a result, /odometry/filtered outputs nearly identical values to /zed/zed_node/odom, which is not what I expected.

To address this, I duplicated the topic /zed/zed_node/pose_with_covariance into a new one /zed/zed_node/pose_cov_for_ekf, but changed the frame_id to "odom". Feeding this to the EKF seems to work: the /odometry/filtered position aligns more closely with the corrected /pose.

However, as a ROS beginner, I’m unsure whether this is the correct approach. Should I have instead set world_frame = "map" in robot_localization and kept the original topic? What is the recommended way to handle this kind of frame inconsistency?


:jigsaw: Additional Context

Due to the hardware configuration, the ZED2i is mounted at a 45° upward angle relative to the mobile robot. When the robot moves forward, the /zed/zed_node/odom Z-position drifts negatively (goes downward), which is incorrect. But the /zed/zed_node/pose output stays aligned with the true vertical axis. This is likely due to set_gravity_as_origin = true, which uses IMU gravity information to keep the orientation aligned with the real-world Z-axis.

Hi @ZaWaLuDo77
Welcome to the Stereolabs community

This is not correct. The pose topic is for localization and can jump when loop closures happen. You must use the odom topic.

Have you added this tilt information to the URDF?

I recommend you read the robot integration guide for more information.

Hi Myzhar:
Thank you for the clarification !

Yes, I originally used the /odom topic, but the result was almost the same as when using the /pose topic (at least before any loop closure occurred). The reason I chose the /pose topic was to take advantage of set_gravity_as_origin = true, which helps keep the Z-axis aligned with gravity.
If I want to use the /odom topic instead, do I need to manually implement a method that uses gravity information from the FOG-IMU to rotate the odometry’s XYZ into alignment with the world frame?

Thank you for the suggestion! I’ll work on adding the tilt information into the URDF.

This parameter is also affecting the /odom/ topic.

However, I tried visualizing the trajectory directly using Three.js by extracting and plotting the following data on a canvas:

  • Blue: /zed/zed_node/pose (pose: x, y, z)
  • Orange: /zed/zed_node/odom (pose: x, y, z)
  • Green: /odometry/filtered (pose: x, y, z)

In my experiment, I moved the robot by roughly the same distance across tests.
I observed the following:

So from what I’ve seen, the set_gravity_as_origin setting significantly affects the /pose, but doesn’t seem to visually influence /odom in the same way in my use case. Let me know if I misunderstood something here.

Hi @ZaWaLuDo77,

Could you please share the common_stereo.yaml config and the zed2i.yaml config so that we can try and reproduce this issue?

common_stereo.yaml

# config/common_stereo.yaml
# Common parameters to Stereolabs ZED Stereo cameras

---
:
    ros__parameters:
        use_sim_time: false # Set to `true` only if there is a publisher for the simulated clock to the `/clock` topic. Normally used in simulation mode.

        simulation:
            sim_enabled: false # Set to `true` to enable the simulation mode and connect to a simulation server
            sim_address: '127.0.0.1' # The connection address of the simulation server. See the documentation of the supported simulation plugins for more information.
            sim_port: 30000 # The connection port of the simulation server. See the documentation of the supported simulation plugins for more information.

        svo:
            use_svo_timestamps: true # Use the SVO timestamps to publish data. If false, data will be published at the system time.
            publish_svo_clock: false # [overwritten by launch file options] When use_svo_timestamps is true allows to publish the SVO clock to the `/clock` topic. This is useful for synchronous rosbag playback.
            svo_loop: false # Enable loop mode when using an SVO as input source. NOTE: ignored if SVO timestamping is used
            svo_realtime: false # if true the SVO will be played trying to respect the original framerate eventually skipping frames, otherwise every frame will be processed respecting the `pub_frame_rate` setting
            play_from_frame: 0 # Start playing the SVO from a specific frame
            replay_rate: 1.0 # Replay rate for the SVO when not used in realtime mode (between [0.10-5.0])

        general:
            camera_timeout_sec: 5
            camera_max_reconnect: 5
            camera_flip: false
            self_calib: true # Enable the self-calibration process at camera opening. See https://www.stereolabs.com/docs/api/structsl_1_1InitParameters.html#affeaa06cfc1d849e311e484ceb8edcc5
            serial_number: 0 # overwritten by launch file
            pub_resolution: 'CUSTOM' # The resolution used for image and depth map publishing. 'NATIVE' to use the same `general.grab_resolution` - `CUSTOM` to apply the `general.pub_downscale_factor` downscale factory to reduce bandwidth in transmission
            pub_downscale_factor: 2.0 # rescale factor used to rescale image before publishing when 'pub_resolution' is 'CUSTOM'
            pub_frame_rate: 30.0 # frequency of publishing of visual images and depth images
            enable_image_validity_check: 1 # [SDK5 required] Sets the image validity check. If set to 1, the SDK will check if the frames are valid before processing.
            gpu_id: -1
            optional_opencv_calibration_file: '' # Optional path where the ZED SDK can find a file containing the calibration information of the camera computed by OpenCV. Read the ZED SDK documentation for more information: https://www.stereolabs.com/docs/api/structsl_1_1InitParameters.html#a9eab2753374ef3baec1d31960859ba19
            async_image_retrieval: false # Enable/disable the asynchronous image retrieval - Note: enable only to improve SVO recording performance

        video:
            brightness: 4 # [DYNAMIC] Not available for ZED X/ZED X Mini
            contrast: 4 # [DYNAMIC] Not available for ZED X/ZED X Mini
            hue: 0 # [DYNAMIC] Not available for ZED X/ZED X Mini
            saturation: 4 # [DYNAMIC]
            sharpness: 4 # [DYNAMIC]
            gamma: 8 # [DYNAMIC]
            auto_exposure_gain: true # [DYNAMIC]
            exposure: 80 # [DYNAMIC]
            gain: 80 # [DYNAMIC]
            auto_whitebalance: true # [DYNAMIC]
            whitebalance_temperature: 42 # [DYNAMIC] - [28,65] x100 - works only if `auto_whitebalance` is false

        sensors:
            publish_imu_tf: false # [overwritten by launch file options] enable/disable the IMU TF broadcasting
            sensors_image_sync: false # Synchronize Sensors messages with latest published video/depth message
            sensors_pub_rate: 100. # frequency of publishing of sensors data. MAX: 400. - MIN: grab rate

        region_of_interest:
            automatic_roi: false # Enable the automatic ROI generation to automatically detect part of the robot in the FoV and remove them from the processing. Note: if enabled the value of `manual_polygon` is ignored
            depth_far_threshold_meters: 2.5 # Filtering how far object in the ROI should be considered, this is useful for a vehicle for instance
            image_height_ratio_cutoff: 0.5 # By default consider only the lower half of the image, can be useful to filter out the sky
            #manual_polygon: '[]' # A polygon defining the ROI where the ZED SDK perform the processing ignoring the rest. Coordinates must be normalized to '1.0' to be resolution independent.
            #manual_polygon: '[[0.25,0.33],[0.75,0.33],[0.75,0.5],[0.5,0.75],[0.25,0.5]]' # A polygon defining the ROI where the ZED SDK perform the processing ignoring the rest. Coordinates must be normalized to '1.0' to be resolution independent.
            #manual_polygon: '[[0.25,0.25],[0.75,0.25],[0.75,0.75],[0.25,0.75]]' # A polygon defining the ROI where the ZED SDK perform the processing ignoring the rest. Coordinates must be normalized to '1.0' to be resolution independent.
            #manual_polygon: '[[0.5,0.25],[0.75,0.5],[0.5,0.75],[0.25,0.5]]' # A polygon defining the ROI where the ZED SDK perform the processing ignoring the rest. Coordinates must be normalized to '1.0' to be resolution independent.
            apply_to_depth: true # Apply ROI to depth processing
            apply_to_positional_tracking: true # Apply ROI to positional tracking processing
            apply_to_object_detection: true # Apply ROI to object detection processing
            apply_to_body_tracking: true # Apply ROI to body tracking processing
            apply_to_spatial_mapping: true # Apply ROI to spatial mapping processing

        depth:
            depth_mode: 'NEURAL_LIGHT' # Matches the ZED SDK setting: 'NONE', 'PERFORMANCE', 'QUALITY', 'ULTRA', 'NEURAL', 'NEURAL_PLUS' - Note: if 'NONE' all the modules that requires depth extraction are disabled by default (Pos. Tracking, Obj. Detection, Mapping, ...)
            depth_stabilization: 30 # Forces positional tracking to start if major than 0 - Range: [0,100]
            openni_depth_mode: false # 'false': 32bit float [meters], 'true': 16bit unsigned int [millimeters]
            point_cloud_freq: 15.0 # [DYNAMIC] - frequency of the pointcloud publishing (equal or less to `pub_frame_rate` value)
            point_cloud_res: 'COMPACT' # The resolution used for point cloud publishing - 'COMPACT'-Standard resolution. Optimizes processing and bandwidth, 'REDUCED'-Half resolution. Low processing and bandwidth requirements
            depth_confidence: 95 # [DYNAMIC]
            depth_texture_conf: 100 # [DYNAMIC]
            remove_saturated_areas: true # [DYNAMIC]

        pos_tracking:
            pos_tracking_enabled: true # True to enable positional tracking from start
            pos_tracking_mode: 'GEN_1' # Matches the ZED SDK setting: 'GEN_1', 'GEN_2'
            imu_fusion: true # enable/disable IMU fusion. When set to false, only the optical odometry will be used.
            publish_tf: true # [overwritten by launch file options] publish `odom -> camera_link` TF
            publish_map_tf: true # [overwritten by launch file options] publish `map -> odom` TF
            map_frame: 'map'
            odometry_frame: 'odom'
            area_memory_db_path: ''
            area_memory: true # Enable to detect loop closure
            reset_odom_with_loop_closure: true # Re-initialize odometry to the last valid pose when loop closure happens (reset camera odometry drift)
            depth_min_range: 0.0 # Set this value for removing fixed zones of the robot in the FoV of the camerafrom the visual odometry evaluation
            set_as_static: false # If 'true' the camera will be static and not move in the environment
            set_gravity_as_origin: true # If 'true' align the positional tracking world to imu gravity measurement. Keep the yaw from the user initial pose.
            floor_alignment: false # Enable to automatically calculate camera/floor offset
            initial_base_pose: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Initial position of the `camera_link` frame in the map -> [X, Y, Z, R, P, Y]
            path_pub_rate: 2.0 # [DYNAMIC] - Camera trajectory publishing frequency
            path_max_count: -1 # use '-1' for unlimited path size
            two_d_mode: false # Force navigation on a plane. If true the Z value will be fixed to 'fixed_z_value', roll and pitch to zero
            fixed_z_value: 0.00 # Value to be used for Z coordinate if `two_d_mode` is true
            transform_time_offset: 0.0 # The value added to the timestamp of `map->odom` and `odom->camera_link` transform being generated
            reset_pose_with_svo_loop: true # Reset the camera pose the `initial_base_pose` when the SVO loop is enabled and the SVO playback reaches the end of the file.

        gnss_fusion:
            gnss_fusion_enabled: false # fuse 'sensor_msg/NavSatFix' message information into pose data
            gnss_fix_topic: '/fix' # Name of the GNSS topic of type NavSatFix to subscribe [Default: '/gps/fix']
            gnss_zero_altitude: false # Set to `true` to ignore GNSS altitude information
            h_covariance_mul: 1.0 # Multiplier factor to be applied to horizontal covariance of the received fix (plane X/Y)
            v_covariance_mul: 1.0 # Multiplier factor to be applied to vertical covariance of the received fix (Z axis)
            publish_utm_tf: true # Publish `utm` -> `map` TF
            broadcast_utm_transform_as_parent_frame: false # if 'true' publish `utm` -> `map` TF, otherwise `map` -> `utm`
            enable_reinitialization: false # determines whether reinitialization should be performed between GNSS and VIO fusion when a significant disparity is detected between GNSS data and the current fusion data. It becomes particularly crucial during prolonged GNSS signal loss scenarios.
            enable_rolling_calibration: true # If this parameter is set to true, the fusion algorithm will used a rough VIO / GNSS calibration at first and then refine it. This allow you to quickly get a fused position.
            enable_translation_uncertainty_target: false # When this parameter is enabled (set to true), the calibration process between GNSS and VIO accounts for the uncertainty in the determined translation, thereby facilitating the calibration termination. The maximum allowable uncertainty is controlled by the 'target_translation_uncertainty' parameter.
            gnss_vio_reinit_threshold: 5.0 # determines the threshold for GNSS/VIO reinitialization. If the fused position deviates beyond out of the region defined by the product of the GNSS covariance and the gnss_vio_reinit_threshold, a reinitialization will be triggered.
            target_translation_uncertainty: 10e-2 # defines the target translation uncertainty at which the calibration process between GNSS and VIO concludes. By default, the threshold is set at 10 centimeters.
            target_yaw_uncertainty: 1e-2 # defines the target yaw uncertainty at which the calibration process between GNSS and VIO concludes. The unit of this parameter is in radian. By default, the threshold is set at 0.1 radians.

        mapping:
            mapping_enabled: false # True to enable mapping and fused point cloud pubblication
            resolution: 0.05 # maps resolution in meters [min: 0.01f - max: 0.2f]
            max_mapping_range: 5.0 # maximum depth range while mapping in meters (-1 for automatic calculation) [2.0, 20.0]
            fused_pointcloud_freq: 1.0 # frequency of the publishing of the fused colored point cloud
            clicked_point_topic: '/clicked_point' # Topic published by Rviz when a point of the cloud is clicked. Used for plane detection
            pd_max_distance_threshold: 0.15 # Plane detection: controls the spread of plane by checking the position difference.
            pd_normal_similarity_threshold: 15.0 # Plane detection: controls the spread of plane by checking the angle difference.

        object_detection:
            od_enabled: false # True to enable Object Detection
            model: 'MULTI_CLASS_BOX_FAST' # 'MULTI_CLASS_BOX_FAST', 'MULTI_CLASS_BOX_MEDIUM', 'MULTI_CLASS_BOX_ACCURATE', 'PERSON_HEAD_BOX_FAST', 'PERSON_HEAD_BOX_ACCURATE', 'CUSTOM_YOLOLIKE_BOX_OBJECTS'
            custom_onnx_file: '' # Only used if 'model' is 'CUSTOM_YOLOLIKE_BOX_OBJECTS'. Path to the YOLO-like ONNX file for custom object detection directly performed by the ZED SDK.
            custom_onnx_input_size: 512 # Resolution used with the YOLO-like ONNX file. For example, 512 means a input tensor '1x3x512x512'
            custom_label_yaml: '' # Only used if 'model' is 'CUSTOM_YOLOLIKE_BOX_OBJECTS'. Path to the COCO-like YAML file storing the custom class labels.
            allow_reduced_precision_inference: true # Allow inference to run at a lower precision to improve runtime and memory usage
            max_range: 20.0 # [m] Defines a upper depth range for detections
            confidence_threshold: 75.0 # [DYNAMIC] - Minimum value of the detection confidence of an object [0,99]
            prediction_timeout: 0.5 # During this time [sec], the object will have OK state even if it is not detected. Set this parameter to 0 to disable SDK predictions
            enable_tracking: true # Defines if the object detection will track objects across images flow
            filtering_mode: 1 # '0': NONE - '1': NMS3D - '2': NMS3D_PER_CLASS
            mc_people: true # [DYNAMIC] - Enable/disable the detection of persons for 'MULTI_CLASS_X' models
            mc_vehicle: true # [DYNAMIC] - Enable/disable the detection of vehicles for 'MULTI_CLASS_X' models
            mc_bag: true # [DYNAMIC] - Enable/disable the detection of bags for 'MULTI_CLASS_X' models
            mc_animal: true # [DYNAMIC] - Enable/disable the detection of animals for 'MULTI_CLASS_X' models
            mc_electronics: true # [DYNAMIC] - Enable/disable the detection of electronic devices for 'MULTI_CLASS_X' models
            mc_fruit_vegetable: true # [DYNAMIC] - Enable/disable the detection of fruits and vegetables for 'MULTI_CLASS_X' models
            mc_sport: true # [DYNAMIC] - Enable/disable the detection of sport-related objects for 'MULTI_CLASS_X' models

        body_tracking:
            bt_enabled: false # True to enable Body Tracking
            model: 'HUMAN_BODY_MEDIUM' # 'HUMAN_BODY_FAST', 'HUMAN_BODY_MEDIUM', 'HUMAN_BODY_ACCURATE'
            body_format: 'BODY_38' # 'BODY_18','BODY_34','BODY_38','BODY_70'
            allow_reduced_precision_inference: false # Allow inference to run at a lower precision to improve runtime and memory usage
            max_range: 20.0 # [m] Defines a upper depth range for detections
            body_kp_selection: 'FULL' # 'FULL', 'UPPER_BODY'
            enable_body_fitting: false # Defines if the body fitting will be applied
            enable_tracking: true # Defines if the object detection will track objects across images flow
            prediction_timeout_s: 0.5 # During this time [sec], the skeleton will have OK state even if it is not detected. Set this parameter to 0 to disable SDK predictions
            confidence_threshold: 50.0 # [DYNAMIC] - Minimum value of the detection confidence of skeleton key points [0,99]
            minimum_keypoints_threshold: 5 # [DYNAMIC] - Minimum number of skeleton key points to be detected for a valid skeleton

        stream_server:
            stream_enabled: false # enable the streaming server when the camera is open
            codec: 'H264' # different encoding types for image streaming: 'H264', 'H265'
            port: 30000 # Port used for streaming. Port must be an even number. Any odd number will be rejected.
            bitrate: 12500 # [1000 - 60000] Streaming bitrate (in Kbits/s) used for streaming. See https://www.stereolabs.com/docs/api/structsl_1_1StreamingParameters.html#a873ba9440e3e9786eb1476a3bfa536d0
            gop_size: -1 # [max 256] The GOP size determines the maximum distance between IDR/I-frames. Very high GOP size will result in slightly more efficient compression, especially on static scenes. But latency will increase.
            adaptative_bitrate: false # Bitrate will be adjusted depending the number of packet dropped during streaming. If activated, the bitrate can vary between [bitrate/4, bitrate].
            chunk_size: 16084 # [1024 - 65000] Stream buffers are divided into X number of chunks where each chunk is chunk_size bytes long. You can lower chunk_size value if network generates a lot of packet lost: this will generates more chunk for a single image, but each chunk sent will be lighter to avoid inside-chunk corruption. Increasing this value can decrease latency.
            target_framerate: 0 # Framerate for the streaming output. This framerate must be below or equal to the camera framerate. Allowed framerates are 15, 30, 60 or 100 if possible. Any other values will be discarded and camera FPS will be taken.

        advanced: # WARNING: do not modify unless you are confident of what you are doing
            # Reference documentation: https://man7.org/linux/man-pages/man7/sched.7.html
            thread_sched_policy: 'SCHED_BATCH' # 'SCHED_OTHER', 'SCHED_BATCH', 'SCHED_FIFO', 'SCHED_RR' - NOTE: 'SCHED_FIFO' and 'SCHED_RR' require 'sudo'
            thread_grab_priority: 50 # ONLY with 'SCHED_FIFO' and 'SCHED_RR' - [1 (LOW) z-> 99 (HIGH)] - NOTE: 'sudo' required
            thread_sensor_priority: 70 # ONLY with 'SCHED_FIFO' and 'SCHED_RR' - [1 (LOW) z-> 99 (HIGH)] - NOTE: 'sudo' required
            thread_pointcloud_priority: 60 # ONLY with 'SCHED_FIFO' and 'SCHED_RR' - [1 (LOW) z-> 99 (HIGH)] - NOTE: 'sudo' required

        debug:
            sdk_verbose: 1 # Set the verbose level of the ZED SDK
            sdk_verbose_log_file: '' # Path to the file where the ZED SDK will log its messages. If empty, no file will be created. The log level can be set using the `sdk_verbose` parameter.
            debug_common: false
            debug_sim: false
            debug_video_depth: false
            debug_camera_controls: false
            debug_point_cloud: false
            debug_positional_tracking: false
            debug_gnss: false
            debug_sensors: false
            debug_mapping: false
            debug_terrain_mapping: false
            debug_object_detection: false
            debug_body_tracking: false
            debug_roi: false
            debug_streaming: false
            debug_advanced: false

zed2i.yaml

# config/zed2i_yaml
# Parameters for Stereolabs zed2i camera
---
/**:
    ros__parameters:
        general:
            camera_model: 'zed2i'
            camera_name: 'zed2i' # overwritten by launch file
            grab_resolution: 'HD720' # The native camera grab resolution. 'HD2K', 'HD1080', 'HD720', 'VGA', 'AUTO'
            grab_frame_rate: 30 # ZED SDK internal grabbing rate

        depth:
            min_depth: 0.3 # Min: 0.3, Max: 3.0
            max_depth: 40.0 # Max: 40.0

When launching ekf_fusion.launch.py using ros2 launch, the resulting TF tree appears as shown in the figure. In addition, I will also evaluate the configuration with the ZED IMU disabled by setting imu_fusion: false.

frames_2025-05-26_19.07.23.pdf (16.1 KB)

Hi @ZaWaLuDo77,

We have been able to test your configuration and have not been able to reproduce on our side. Can you confirm that you can see the difference in results from setting the set_gravity_as_origin from a clean build of the zed-ros2-wrapper without any modifications?

I’d like to share a photo showing the mounting setup of the ZED2i and the FOG-IMU.
The ZED2i is installed at a 45-degree upward tilt relative to the robot’s base frame.
As a result, when the robot moves forward in a straight line, I observe that the z value in the /odom topic’s pose keeps decreasing — likely due to the camera’s tilted mounting angle.

Hi @ZaWaLuDo77

The TF tree is wrong. If you are using an external Kalman Filter, then the zed_camera_link must be a child of base_link and you must disable the parameter publish_tf of the ZED Node.

This is explained in the Robot Integration documentation.

Thank you for pointing out the issue!

Currently, I’ve made the following adjustments without using the URDF (since my motors don’t have encoders, and I only need to configure the FOG-IMU and ZED2i), and it seems the problem is now resolved:

In common_stereo.yaml (Snippet code):

# ....
pos_tracking:
    pos_tracking_enabled: true 
    pos_tracking_mode: 'GEN_1' 
    imu_fusion: false 
    publish_tf: false 
    publish_map_tf: true 
    map_frame: 'map'
    odometry_frame: 'base_link' # original : odom !!
    area_memory: false 
    area_file_path: '~/test_area_memory.area'

# ....

In ekf_fusion.launch.py:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        # Static transform: base_link → imu_link
        # IMU is mounted at the center of the robot base
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            name='base_to_imu',
            arguments=['0', '0', '0.1', '0', '0', '0', 'base_link', 'imu_link'],
        ),
        
        # Static transform: base_link → zed_camera_center
        # ZED camera is mounted forward of the robot base
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            name='base_to_zed',
            arguments=['0.2', '0', '0.15', '0', '0', '0', 'base_link', 'zed_camera_link'], 
        ),

        # EKF node
        Node(
            package='robot_localization',
            executable='ekf_node',
            name='ekf_filter',
            output='screen',
            parameters=[{
                'use_sim_time': False,
                'frequency': 100.0,
                'sensor_timeout': 0.1,
                'two_d_mode': False,
                'transform_tolerance': 0.1,
                'publish_tf': True,
                'publish_acceleration': False,
                
                # Frame configuration
                'map_frame': 'map',
                'odom_frame': 'odom', 
                'base_link_frame': 'base_link',
                'world_frame': 'odom',
                
                # IMU configuration
                'imu0': '/Fog_imu/imu_data',
                'imu0_config': [
                    False, False, False,  # position (x, y, z) - not used from IMU
                    True,  True,  True,   # orientation (roll, pitch, yaw) - use all
                    False, False, False,  # linear velocity (vx, vy, vz) - not from IMU
                    True,  True,  True,   # angular velocity (vroll, vpitch, vyaw) - use all
                    False, False, False,   # linear acceleration (ax, ay, az) - use all for better fusion
                ],
                'imu0_differential': False,
                'imu0_relative': False,
                'imu0_queue_size': 50,
                'imu0_remove_gravitational_acceleration': True,

                # ZED odometry configuration
                'odom0': '/zed/zed_node/odom',
                'odom0_config': [
                    True,  True,  True,   # position (x, y, z) - use all
                    False, False, False,    # orientation (roll, pitch, yaw) - only yaw
                    False, False, False,   # linear velocity (vx, vy, vz) - x,y only
                    False, False, False,    # angular velocity (vroll, vpitch, vyaw) - only vyaw
                    False, False, False   # linear acceleration (ax, ay, az) - not from odom
                ],
                'odom0_differential': False,
                'odom0_relative': False,
                'odom0_queue_size': 10,
                
                # Process noise covariance (increase for faster convergence if needed)
                'process_noise_covariance': [
                    0.05, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.05, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.06, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.03, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.03, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.06, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.025,0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.025,0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.04, 0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.01, 0.0,  0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.01, 0.0,  0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.02, 0.0,  0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.01, 0.0,  0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.01, 0.0,
                    0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.015
                ]
            }]
        )
    ])

TF Tree (see tf2_tree.png):

frames_2025-09-17_11.11.43.pdf (16.0 KB)

Now, zed_camera_link is a child of base_link, which matches the expected setup when using an external Kalman filter.

After these changes, the /odometry/filtered output now behaves as expected.
However, I’ve noticed some noticeable drift caused by the integration of angular velocity over time, which seems to accumulate — but that’s a separate topic.

Thanks again for your help!

1 Like