How to connect two disconnected tf trees?
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
Asked by Batstru on 2020-12-16 14:58:35 UTC
Answers
Couple of notes:
- Typically, the link between
base_footprint
andcamera_rgb_optical_frame
would not be provided by a static transform publisher, but would instead be provided by the URDF and an instance of therobot_state_publisher
. Based on thetf
tree linked in the question, that would mean that thecamera_link
would need to be added to the URDF. - 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 fromodom
tobase_footprint
comes from odometry information such as wheel encoders and IMUs). If your camera is attached to your robot, the transform fromodom
tocamera_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. theodom
frame. Rather, the you likely want to express thecamera_link
w.r.t. thebase_link
(you'd be specifying the pose of the camera relative to thebase_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 thestatic_transform_publisher
accepts you'll see that there are 2 forms: the first uses 6 floats before theframe_id
and represents rotation as RPY, and the second uses 7 floats beforeframe_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 be0 0 0 1
. This mistake is where theTF_NAN_INPUT
is likely coming from in your second error message.
- Your usage of the arguments to
Asked by jarvisschultz on 2020-12-16 17:27:16 UTC
Comments
Thanks, I go back and do the homework now :-) I might come back in some time!
Asked by Batstru on 2020-12-17 14:49:58 UTC
Comments