ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Robot_localization ekf node does not subscribe to Odom topic

asked 2022-08-30 11:53:49 -0500

LiquidTurtle1 gravatar image


I am trying to fuse my odometry from my 2D differential drive robot, with my imu using the ekf from RL. The odometry works fine on it's own, but I think I must be missing something simple in my config files as I cannot get the ekf node to subscribe to the odom topic I am publishing.

    frequency: 30.0
    sensor_timeout: 0.1
    two_d_mode: true
    transform_time_offset: 0.0
    transform_timeout: 0.0
    print_diagnostics: true
    debug: false
    publish_tf: true
    publish_acceleration: false
    map_frame: map              
    odom_frame: odom          
    base_link_frame: base_link 
    world_frame: odom           
    odom0: /odom/data     #does not appear under $ros2 node info
    odom0_config: [true, true, true,
                   false, false, false,
                   false, false, false,
                   false, false, true,
                   false, false, false]
    odom0_queue_size: 5
    odom0_nodelay: true
    odom0_differential: true
    odom0_relative: false
    odom0_pose_rejection_threshold: 5.0
    odom0_twist_rejection_threshold: 1.0
    imu0: /imu/data     #ekf properly subscribes to this topic
    imu0_config: [false,  false,  false,
                  false,  false,  false,
                  false,  false,  false,
                  false,  false,  true,
                  true,   false,  false]
    imu0_nodelay: false
    imu0_differential: false
    imu0_relative: true
    imu0_queue_size: 10
    imu0_pose_rejection_threshold: 0.8                
    imu0_twist_rejection_threshold: 0.8                
    imu0_linear_acceleration_rejection_threshold: 0.8  
    imu0_remove_gravitational_acceleration: true
    use_control: false
    stamped_control: false
    control_timeout: 0.2
    control_config: [true, false, false, false, false, true]


I am generating my transforms from the ros2_differential_drive package:

    self.base_frame_id = self.declare_parameter('base_frame_id', 'base_link').value  
    self.odom_frame_id = self.declare_parameter('odom_frame_id', 'odom')

    self.create_subscription(Int16, "lwheel", self.lwheel_callback, 10)
            self.create_subscription(Int16, "rwheel", self.rwheel_callback, 10)
            self.odom_pub = self.create_publisher(Odometry, "odom/data", 10)
            self.odom_broadcaster = TransformBroadcaster(self)

        transform_stamped_msg = TransformStamped()
        transform_stamped_msg.header.stamp = self.get_clock().now().to_msg()
        transform_stamped_msg.header.frame_id = self.odom_frame_id
        transform_stamped_msg.child_frame_id = self.base_frame_id
        transform_stamped_msg.transform.translation.x = self.x
        transform_stamped_msg.transform.translation.y = self.y
        transform_stamped_msg.transform.translation.z = 0.0
        transform_stamped_msg.transform.rotation.x = quaternion.x
        transform_stamped_msg.transform.rotation.y = quaternion.y
        transform_stamped_msg.transform.rotation.z = quaternion.z
        transform_stamped_msg.transform.rotation.w = quaternion.w


        odom = Odometry()
        odom.header.stamp = now.to_msg()
        odom.header.frame_id = self.odom_frame_id
        odom.pose.pose.position.x = self.x
        odom.pose.pose.position.y = self.y
        odom.pose.pose.position.z = 0.0
        odom.pose.pose.orientation = quaternion
        odom.child_frame_id = self.base_frame_id
        odom.twist.twist.linear.x = self.dx
        odom.twist.twist.linear.y = 0.0
        odom.twist.twist.angular.z = self.dr

I would greatly appreciate any advice you have. Thank you!

edit retag flag offensive close merge delete


Just to clarify, the differential_drive package publishes data of type nav_msgs/Odometry, so it should be accessible to RL

Publishers: /odom/data: nav_msgs/msg/Odometry

LiquidTurtle1 gravatar image LiquidTurtle1  ( 2022-08-30 12:00:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-09-13 08:23:37 -0500

LiquidTurtle1 gravatar image

updated 2022-09-14 11:52:44 -0500

I was able to get the node to subscribe to the odometry topic by adding {'odom0': '/odom/data'} to my launch file:

        output = 'screen',
        parameters=[os.path.join(get_package_share_directory("mlabot"), 'config', 'ekf.yaml'), {'odom0': '/odom/data'}],
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-08-30 11:53:49 -0500

Seen: 103 times

Last updated: Sep 14 '22