Robot_localization doesnt work with Rosbag file
I want to fuse the visual odometry of my Intel Realsense T265 camera with the wheel odometry of my AGV (Mechanum wheels). I am using the ekf_node with default covariances and the default launch file on Ros2 Eloquent. (files at the bootom) If I do it on the Robot itself everything works fine. The output of "/odometry/filtered" works fine and everything is calculated as it should. Now the Problem: If I record the exact same data from the robot with a rosbag2 and than try to calculate Robot_localization on my VM the estimated position goes crazy (values over 40000 in x for example). I record everything with the rosbag, so there is no difference except for the not running ekf node of course.
As far as I tested the error occured everytime I try to the Visual odometry signal or if I run the ekf a second time after stopping. After a reboot of the VM the first run is working, if there is only the wheel_odometry signal in the ekf. I am not sure if that is related or random.
I already tried swapping odom0 with odom1 and trying out different combinations in the config matrices. Like fusing position from both or x from the one, y from the other. Just experiments. But nothing helped.
Is this a known issue? Did I miss a setting that I need to get this going? A colleague mentioned it could be an issue with the recorded time?
Thanks in advance!
The used Launchfile:
from launch import LaunchDescription
from ament_index_python.packages import get_package_share_directory
import launch_ros.actions
import os
import yaml
from launch.substitutions import EnvironmentVariable
import pathlib
import launch.actions
from launch.actions import DeclareLaunchArgument
def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
package='robot_localization',
node_executable='ekf_node',
node_name='ekf_filter_node',
output='screen',
parameters=[os.path.join(get_package_share_directory("robot_localization"), 'params', 'ekf_t265.yaml')],
),
])
yaml file:
### ekf config file ###
ekf_filter_node:
ros__parameters:
frequency: 30.0
two_d_mode: true
odom0: /odom #wheel_odometry
odom0_config: [false, false, false,
false, false, true,
false, false, false,
false, false, false,
false, false, false]
odom0_differential: true
odom1: /camera/odom/sample #VIO
odom1_config: [true, true, false,
false, false, false,
false, false, false,
false, false, false,
false, false, false]
odom1_differential: true
odom_frame: odom
base_link_frame: odom_frame
world_frame: odom
publish_tf: true
Update according to comment:
I changed the Frames. My TF Tree now looks like: odom
-> base_link
-> camera_pose_optical_frame
.
My base_link frame now is base_link
which is also the child frame of the wheel_odometry.
Furthermore the transform: base_link
-> child_frame of the camera camera_pose_optical_frame
should now be as you mentioned.
I still get this Warning: Warning: Invalid frame ID "odom" passed to canTransform argument target_frame - frame does not exist
I hope I did not misunderstood or missed something from your comment.
Here is my yaml-file:
ekf_filter_node:
ros__parameters:
frequency: 30.0
use_sim_time: true
two_d_mode: true
odom0: /odom
odom0_config: [false, false, false,
false, false, false,
true, true, false,
false, false, false,
false, false, false]
odom0_differential: false
odom1: /camera/odom/sample
odom1_config: [true, true, false,
false, false, true,
false, false, false,
false ...