TF error, no source frame

asked 2019-08-21 13:48:23 -0500

EdwardNur gravatar image

I have a tf from map to camera_link and I am using AMCL style code to create a TF from Map to odom to correct my odometry due to drift. However, when I run this code:

tf::Stamped<tf::Pose> odom_to_map;
    try
    {
        tf::Transform tmp_tf = TransformFromMat (position);
        tf::Stamped<tf::Pose> tmp_tf_stamped (tmp_tf.inverse(),
                                              current_frame_time_,
                                              camera_frame_id_param_);

        listener_.transformPose("odom", tmp_tf_stamped, odom_to_map);
    }
    catch (tf::TransformException)
    {
        ROS_DEBUG("Failed to substruct left_camera_link to odom transform");
        return;
    }

    tf::Transform latest_tf(tf::Quaternion(odom_to_map.getRotation()),
                            tf::Point(odom_to_map.getOrigin()));

    //ros::Time transform_expiration = (current_frame_time_.toSec());
    tf::StampedTransform tmp_tf_stamped(latest_tf.inverse(),
                                        current_frame_time_ + ros::Duration(0.1),
                                        map_frame_id_param_,
                                        "odom");


    static tf::TransformBroadcaster tf_broadcaster;
    tf::Transform transform = this->TransformFromMat(position);
    tf_broadcaster.sendTransform(tf::StampedTransform(transform, current_frame_time_, map_frame_id_param_, camera_frame_id_param_));

I get this warning:

[ WARN] [1566413067.333379658]: Could not obtain transform from map to odom. Error was "map" passed to lookupTransform argument source_frame does not exist. 

[ WARN] [1566413067.580395075]: Transform from map to odom was unavailable for the time requested. Using latest instead.

What could be wrong? If I do not do anything and let map to camera_link live without transforming it to map to odom, I get that TF but of course my tree becomes wrong and broken.

edit retag flag offensive close merge delete