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

Transform link missing from base_footprint -> odom

asked 2022-04-22 19:46:16 -0500

factos07 gravatar image


I am new to ROS and I am trying to make an indoor autonomous robot. However, I am getting an error when connecting the tf frame base_link to odom. I have linked a screenshot of the error. I am not sure what the cause of this error is. We used and adapted a good amount of code from Automatic Addison, although we use the MPU 6050 and different robot. I believe that the code could be an issue in our topic names; something that is occuring is that the code is mapping to imu/imu/data instead of what we want, which is just imu/data (only one), but we can't find in the code where exactly this changes. All the odom data is publishing in our ekf_odom_pub, attached below. I've also attached a picture of the TF tree, which shows that the odom/base_link is not linked. Any help or pointers would be awesome!

We have tried things like rostopic echo, list, etc, and data is printing for odom and imu. We suspect that because of this that it isn't a data issue but just a tf pub/sub issue.

Thank you! ROS TREE


#include "ros/ros.h"
#include "std_msgs/Int16.h"
#include <nav_msgs/Odometry.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <cmath>

// Create odometry data publishers
ros::Publisher odom_data_pub;
ros::Publisher odom_data_pub_quat;
nav_msgs::Odometry odomNew;
nav_msgs::Odometry odomOld;

// Initial pose
const double initialX = 0.0;
const double initialY = 0.0;
const double initialTheta = 0.00000000001;
const double PI = 3.141592;

// Robot physical constants
const double TICKS_PER_REVOLUTION = 620; // For reference purposes.
const double WHEEL_RADIUS = 0.033; // Wheel radius in meters
const double WHEEL_BASE = 0.165; // Center of left tire to center of right tire
const double TICKS_PER_METER = 2700; // Original was 2800

// Distance both wheels have traveled
double distanceLeft = 0;
double distanceRight = 0;

// Flag to see if initial pose has been received
bool initialPoseRecieved = false;

using namespace std;

// Get initial_2d message from either Rviz clicks or a manual pose publisher
void set_initial_2d(const geometry_msgs::PoseStamped &rvizClick) {

  odomOld.pose.pose.position.x = rvizClick.pose.position.x;
  odomOld.pose.pose.position.y = rvizClick.pose.position.y;
  odomOld.pose.pose.orientation.z = rvizClick.pose.orientation.z;
  initialPoseRecieved = true;

// Calculate the distance the left wheel has traveled since the last cycle
void Calc_Left(const std_msgs::Int16& leftCount) {

  static int lastCountL = 0;
  if( != 0 && lastCountL != 0) {

    int leftTicks = ( - lastCountL);

    if (leftTicks > 10000) {
      leftTicks = 0 - (65535 - leftTicks);
    else if (leftTicks < -10000) {
      leftTicks = 65535-leftTicks;
    distanceLeft = leftTicks/TICKS_PER_METER;
  lastCountL =;

// Calculate the distance the right wheel has traveled since the last cycle
void Calc_Right(const std_msgs::Int16& rightCount) {

  static int lastCountR = 0;
  if( != 0 && lastCountR != 0) {

    int rightTicks = - lastCountR;

    if (distanceRight > 10000) {
      distanceRight = (0 - (65535 - distanceRight))/TICKS_PER_METER;
    else if (rightTicks < -10000) {
      rightTicks = 65535 - rightTicks;
    distanceRight = rightTicks/TICKS_PER_METER;
  lastCountR =;

// Publish a nav_msgs::Odometry message in quaternion format
void publish_quat() {

  tf2 ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-04-25 09:32:57 -0500

Joe28965 gravatar image

I'm pretty sure that TF doesn't like it when one link has multiple parents. Please use base_footprint instead of base_link for your connection with odom.

The error actually doesn't say anything useful. It's just costmap telling you there isn't a connection between the two, there's no more information than that.

something that is occuring is that the code is mapping to imu/imu/data instead of what we want, which is just imu/data (only one)

As for that, have you used a namespace? If so, the namespace is the first imu and if you then use the topic imu/data you get ns+topic=imu/imu/data.

edit flag offensive delete link more


Confirmed, you cannot have multiple parents in a tf tree. Every time it's published with a different parent you will break and reform the tree connected to the most recently published parent.

tfoote gravatar image tfoote  ( 2022-04-25 14:51:17 -0500 )edit

Update: We found out ekf_robot_pose was feeding to odom_combined and not odom, and so we changed all things to odom and were able to get the tf tree correct!

However, we are still running into IMU errors because of the /imu/imu/data when it should be /imu/data (probably because of namespace like you suggested but we are a little confused by what that means and how it even ended up being different in the first place; would this be something we configured in our launch file?)

factos07 gravatar image factos07  ( 2022-04-25 17:39:02 -0500 )edit

Yes, it's probably your launch file. What node subscribes to /imu/imu/data? Do you configure it yourself? Do you tell it that the topic is /imu/data? What happens if you tell it to subscribe simply to data?

If you want you could edit the post to add your launch file to the post, that way we could help you answer that question, although technically it's a separate question at this point since your original question has been resolved.

Joe28965 gravatar image Joe28965  ( 2022-04-26 02:32:16 -0500 )edit

I posted a better explanation here:

It contains a snippet of the launch file pertaining to the IMU part

Thank you so much!

factos07 gravatar image factos07  ( 2022-04-26 16:07:12 -0500 )edit i hope this issue might be similar to yours, could you solve it.

iamsdevaprasad gravatar image iamsdevaprasad  ( 2023-07-19 21:25:40 -0500 )edit

Question Tools


Asked: 2022-04-22 19:43:17 -0500

Seen: 563 times

Last updated: Apr 25 '22