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

How to connect two disconnected tf trees?

asked 2020-12-16 13:58:35 -0600

Batstru gravatar image

updated 2020-12-16 13:58:48 -0600

Dear all,

My robot is based on a roomba, on top of which I placed a kinect v1. Ros melodic is the software I run, on an ubuntu 18.04 lts.

I'm trying to do mapping with rtabmap, I'm following this tutorial.

I'm stuck on this error: actually the tf tree is really splt in two (here the output of "rosrun tf view_frames")

[ WARN] [1607975443.437600036]: Could not get transform from base_footprint to camera_rgb_optical_frame after 0.200000 seconds (for stamp=1607975443.136633)! Error="Could not find a connection between 'base_footprint' and 'camera_rgb_optical_frame' because they are not part of the same tree.Tf has two or more unconnected trees.. canTransform returned after 0.200822 timeout was 0.2.".

I read I should apply a static transformation, so I added the line in the launch file... however it's still not working, I see this error:

Error:   TF_NAN_INPUT: Ignoring transform for child_frame_id "odom" from authority "unknown_publisher" because of a nan value in the transform (0.000000 0.000000 0.000000) (nan nan nan nan)
         at line 244 in /tmp/binarydeb/ros-melodic-tf2-0.6.5/src/buffer_core.cpp

This is my launch file:

<launch>

  <node pkg="tf" type="static_transform_publisher" name="link" args="0 0 0 0 0 0 0 camera_link odom 100" />

  <!-- Kinect cloud to laser scan -->
    <node pkg="depthimage_to_laserscan" type="depthimage_to_laserscan" name="depthimage_to_laserscan">
      <remap from="image"       to="/camera/depth_registered/image_raw"/>
      <remap from="camera_info" to="/camera/depth_registered/camera_info"/>
      <remap from="scan"        to="/kinect_scan"/>
      <param name="range_max" type="double" value="4"/>
    </node>

  <!-- SLAM -->
  <group ns="rtabmap">
    <node name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="--delete_db_on_start">
          <param name="frame_id" type="string" value="base_footprint"/>

          <param name="subscribe_depth" type="bool" value="true"/>
          <param name="subscribe_scan" type="bool" value="true"/>

          <remap from="odom" to="/odom"/>
          <remap from="scan" to="/kinect_scan"/>

          <remap from="rgb/image"       to="/camera/rgb/image_rect_color"/>
          <remap from="depth/image"     to="/camera/depth_registered/image_raw"/>
          <remap from="rgb/camera_info" to="/camera/rgb/camera_info"/>

          <param name="queue_size" type="int" value="10"/>

          <!-- RTAB-Map's parameters -->
          <param name="RGBD/ProximityBySpace"     type="string" value="false"/>
          <param name="RGBD/AngularUpdate"        type="string" value="0.01"/>
          <param name="RGBD/LinearUpdate"         type="string" value="0.01"/>
          <param name="RGBD/OptimizeFromGraphEnd" type="string" value="false"/>
          <param name="Reg/Force3DoF"             type="string" value="true"/>
          <param name="Vis/MinInliers"            type="string" value="12"/>
    </node>
  </group>
</launch>

Do you have any suggestion? I'm not quite sure the approach to link the two branches of the tf tree is the most appropriate: please suggest what's the best approach to do so, I admit this is quite an overshooting for a beginner with ros like me.

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-12-16 16:27:16 -0600

updated 2020-12-16 16:28:15 -0600

Couple of notes:

  1. Typically, the link between base_footprint and camera_rgb_optical_frame would not be provided by a static transform publisher, but would instead be provided by the URDF and an instance of the robot_state_publisher. Based on the tf tree linked in the question, that would mean that the camera_link would need to be added to the URDF.
  2. Even though the previous point is true, that doesn't mean you can't use a static_transform_publisher. In your case, I see a few problems with the first <node> tag in your launch file:

    • Most likely, your camera is physically attached to your robot. The odom frame represents how the robot thinks it has moved while driving around (i.e. the transform from odom to base_footprint comes from odometry information such as wheel encoders and IMUs). If your camera is attached to your robot, the transform from odom to camera_link would not be static, it would be a function of odometry (meaning a static transform publisher would not be appropriate). I doubt you actually mean to express the pose of the camera w.r.t. the odom frame. Rather, the you likely want to express the camera_link w.r.t. the base_link (you'd be specifying the pose of the camera relative to the base_link of your robot, which never changes).

    • Your usage of the arguments to static_transform_publisher are invalid. If you study the docs for the arguments that the static_transform_publisher accepts you'll see that there are 2 forms: the first uses 6 floats before the frame_id and represents rotation as RPY, and the second uses 7 floats before frame_id and represents rotation as a Quaternion. You are using 7, but the provided Quaternion is invalid because its norm is not 1.0 (you have all zeros). An identity quaternion would be 0 0 0 1. This mistake is where the TF_NAN_INPUT is likely coming from in your second error message.

edit flag offensive delete link more

Comments

1

Thanks, I go back and do the homework now :-) I might come back in some time!

Batstru gravatar image Batstru  ( 2020-12-17 13:49:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-12-16 13:58:35 -0600

Seen: 1,605 times

Last updated: Dec 16 '20