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

Unable to create a TF2 Broadcaster from odom to base_link

asked 2022-05-19 10:44:45 -0600

marcelomm103 gravatar image

Hi everyone!

I'm having troubles creating my own TF2 broadcaster to publish a tf from odom to base_link. I'm using a .sdf file in gazebo ignition fortress and not an urdf so i cant use robot_state_publisher, and i think i have to create a custom broadcaster to solve the lack of tf in the odom to base_link frames. I tried following the tutorial at (https://docs.ros.org/en/rolling/Tutor...) but had no success.

I'm using ROS 2 Foxy with ubuntu focal 20.04 and gazebo ignition fortress.

My ign topic list is as follow:

/clock /gazebo/resource_paths /gui/camera/pose /model/prius_hybrid/cmd_vel /model/prius_hybrid/imu /model/prius_hybrid/laserscan /model/prius_hybrid/laserscan/points /model/prius_hybrid/odometry /stats /world/empty/clock /world/empty/dynamic_pose/info /world/empty/model/prius_hybrid/joint_state /world/empty/pose/info /world/empty/scene/deletion /world/empty/scene/info /world/empty/state /world/empty/stats

If i echo the /world/empty/pose/info i got at the prius_hybrid pose the following:

pose { name: "prius_hybrid" id: 8 position { x: 5.43665402911271 y: 2.1081258650307535 z: 0.012649947145117342 } orientation { x: 2.6633471804933985e-09 y: -1.5456830808628278e-08 z: 0.97151594503524608 w: -0.23697419383188628 } }

I'm using ign_bridge to port topics to ros2, echoing the odometry, imu and laser i verified it's all working as it should, like i can view lidar data on rviz2. But if i try to use slam_toolbox for example or robot_localization it misses the odom to base_link tf.

If anyone has any suggestion all help will be appreciated, thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2022-05-20 02:12:47 -0600

Per Edwardsson gravatar image

The odom->base_link transform is responsible for keeping track of the motion of the robot based on its odometry sensors. This is the primary way that other systems can find the location of the robot in the world. You could use an EKF, like robot_localization, to produce this odometry. Small sidenote: I find this package to be one of the greatest unsung heroes in the ROS/ROS2 ecosystem. It is incredibly flexible, well documented, and does a fantastic job in producing ego motion. It also produces the odom->base_link transform that you seek.

edit flag offensive delete link more

Comments

Also, C++ and Python tutorials on how to create a broadcaster in Foxy yourself. However, I agree that it's best to use robot_localization in your case.

Joe28965 gravatar image Joe28965  ( 2022-05-20 03:06:31 -0600 )edit
0

answered 2022-05-20 12:24:32 -0600

marcelomm103 gravatar image

updated 2022-05-22 12:19:08 -0600

Thank you all for your replies. I'm trying to use robot_localization fusing imu data with odometry data and run it without erros, but when i echo the /odometry/filtered topic nothing appears, same with /tf.

My topic echo of /imu:

header: stamp: sec: 405 nanosec: 0 frame_id: prius_hybrid/base_link/imu_sensor orientation: x: -1.2904867439912974e-08 y: -8.884622699800979e-09 z: 0.5100525000587437 w: 0.8601432713123001 orientation_covariance: - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 angular_velocity: x: -2.1760478011178761e-10 y: 3.2708010168366545e-09 z: -0.10292681816398133 angular_velocity_covariance: - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 linear_acceleration: x: -0.029515892240106825 y: 0.011729909753287195 z: 9.800000000414627 linear_acceleration_covariance: - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0

My topic echo of /odom:

header: stamp: sec: 445 nanosec: 280000000 frame_id: prius_hybrid/odom child_frame_id: prius_hybrid/base_link pose: pose: position: x: 1.9721655961355304 y: -1.3924259318057075 z: 0.0 orientation: x: 0.0 y: 0.0 z: -0.6374588776606153 w: 0.7704843796545578 covariance: - 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.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 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 twist: twist: linear: x: 0.5000000001871285 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: -0.30170957019307537 covariance: - 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.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 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0

My ekf.yaml params file:

´ ekf_filter_node: ros__parameters: use_sim_time: true 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 debug_out_file: /path/to/debug/file.txt publish_tf: true publish_acceleration: false reset_on_time_jump: true map_frame: map
odom_frame: prius_hybrid/odom
base_link_frame: prius_hybrid/base_link
world_frame: prius_hybrid/odom

    odom0: odom
    odom0_config: [true, true, true,
                   false, false, false,
                   true,  true,  true,
                   false, false, true,
                   false, false, false]

    odom0_queue_size: 2

    odom0_nodelay: false

    odom0_differential: false

    odom0_relative: false

    odom0_pose_rejection_threshold: 5.0
    odom0_twist_rejection_threshold: 1.0

    imu0: imu
    imu0_config: [false, false, false,
                  true,  true,  true,
                  false, false, false,
                  true,  true,  true,
                  true,  true,  true]

    imu0_nodelay: false
    imu0_differential: false
    imu0_relative: true
    imu0_queue_size: 7
    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]

    acceleration_limits: [1.3, 0.0, 0.0, 0.0, 0.0, 3.4]

    deceleration_limits: [1.3 ...
(more)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-05-19 10:44:45 -0600

Seen: 623 times

Last updated: May 22 '22