Ask Your Question
0

Tf has two or more unconnected trees

asked 2018-06-26 08:45:35 -0500

updated 2018-06-27 05:31:53 -0500

Hey! I was trying to use a Kinect fusion package for my project on Robot Workcell Discovery. I am using ROS Kinetic and Ubuntu 16.04.

While launching the Kinect fusion node, I face the following error.

terminate called after throwing an instance of 'tf2::LookupException'. what(): Could not find a connection between 'volume_pose' and 'camera_depth_optical_frame' because they are not part of the same tree. Tf has two or more unconnected trees.

How as per the Link to the tf frames.pdf file generated created using rosrun tf view_frames these two frames seem to be in the same tree.

On some occasions, the same launch file gives the following error. terminate called after throwing an instance of 'tf2::LookupException' what(): "volume_pose" passed to lookupTransform argument target_frame does not exist.

This is the related code

if (!camera->nodeHandle.getParam("use_pose_hints", use_pose_hints_)) 
{
    ROS_INFO("Failed to get use_pose_hints flag!");
  }
 ROS_INFO_STREAM("Use pose hints set to " << use_pose_hints_);
 tfListener_.waitForTransform("volume_pose", "camera_depth_optical_frame", ros::Time::now(), ros::Duration(2));
tfListener_.lookupTransform("volume_pose", "camera_depth_optical_frame", ros::Time(0), previous_volume_to_sensor_transform_);
 }
    }

I have added Listener. waitForTransform() as mentioned in this answer. I have also added <param name="/use_sim_time" value="true"/> on the top of my launch files as as mentioned by some other answers, however the problem still persists.

There definitely seems to be a problem of the volume_pose not being available in time. What could be the potential reason and solution for this issue?

Edit: In one case, I received this error message as well which according to this link is again due to a delayed source of frames.

Warning: TF_OLD_DATA ignoring data from the past for frame table at time 0.165 according to authority unknown_publisher

Output of tf monitor

Waiting for transform chain to become available between volume_pose and camera_depth_optical_frame 

RESULTS: for volume_pose to camera_depth_optical_frame
 Chain is: volume_pose -> base_link -> table -> world -> shoulder_link -> upper_arm_link -> forearm_link -> wrist_1_link -> wrist_2_link -> wrist_3_link -> tool0 -> camera_link -> camera_depth_frame -> camera_depth_optical_frame
Net delay     avg = 0.00997896: max = 0.099

Frames:
Frame: base_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: camera_depth_frame published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: camera_depth_optical_frame published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: camera_link published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: forearm_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003
Frame: shoulder_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003
Frame: table published by unknown_publisher Average Delay: -0.0666667 Max Delay: 0
Frame: tool0 published by unknown_publisher(static) Average Delay: 0 Max Delay: 0
Frame: upper_arm_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003
Frame: volume_pose published by unknown_publisher Average Delay: 0 Max Delay: 0
Frame: wrist_1_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003
Frame: wrist_2_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003
Frame: wrist_3_link published by unknown_publisher Average Delay: 0.000272727 Max Delay: 0.003

All Broadcasters:
Node: unknown_publisher 85 Hz, Average Delay: -0.0233529 Max Delay: 0.003
Node: unknown_publisher ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-06-27 08:36:46 -0500

Hi!

Just for anyone facing a similar issue in the future.

Instead of

if (!camera->nodeHandle.getParam("use_pose_hints", use_pose_hints_)) 
{
    ROS_INFO("Failed to get use_pose_hints flag!");
  }
 ROS_INFO_STREAM("Use pose hints set to " << use_pose_hints_);
 tfListener_.waitForTransform("volume_pose", "camera_depth_optical_frame", ros::Time::now(), ros::Duration(2));
tfListener_.lookupTransform("volume_pose", "camera_depth_optical_frame", ros::Time(0), previous_volume_to_sensor_transform_);
 }
    }

I added a try-catch block as per the tf tutorials.

if (use_pose_hints_) {
    try {
  tfListener_.waitForTransform("volume_pose", "camera_depth_optical_frame", ros::Time::now(), ros::Duration(0.5));
  tfListener_.lookupTransform("volume_pose", "camera_depth_optical_frame", ros::Time(0), previous_volume_to_sensor_transform_);
    }
    catch (tf::TransformException ex){
        ROS_ERROR("%s", ex.what());
    }
}

}

This allowed time for the volume_pose frame to become available when the Kinect fusion node was launched.

And in case the frame is not available the following message will be shown.

[ERROR] [1530122898.477899539, 10.817000000]: "volume_pose" passed to lookupTransform argument target_frame does not exist.

Refer to this issue and this pull request if more details are required.

edit flag offensive delete link more
0

answered 2018-06-26 09:40:29 -0500

The problem seems to be with the age of some of these transformations. If you look at the PDF file you linked to quite a few of the TF links are 47 seconds old, if this is longer than the TF buffer used to try and resolve the queries this will result in the failure your described.

Are you running a system on two different computers with some TF's being produced on one of them and some on the other one? Since ROS uses the system clock of the computer this time offset could be caused by the two system clocks being out of sync.

This Answers has a good description of how to fix this using the Chony tool.

If you can sync the time of your two computers then hopefully this problem will be fixed.

edit flag offensive delete link more

Comments

Hey Pete! Thanks a lot for your reply. So actually I am not using different machines. It's all running on the same machine. I am launching my model in Gazebo and in RViz using MoveIt! using two separate launch files. And then I am launching the Kinect fusion package using a separate launch file.

aaditya_saraiya gravatar imageaaditya_saraiya ( 2018-06-27 01:58:12 -0500 )edit

Is the time delay created because I am launching them separately? Should I be launching everything together?

Edit: The startup delay in Gazebo and RViz is there and in one more trial, there is still 35 seconds delay in the frames.

Thanks in advance.

aaditya_saraiya gravatar imageaaditya_saraiya ( 2018-06-27 01:59:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-06-26 08:45:35 -0500

Seen: 495 times

Last updated: Jun 27 '18