odom and base_footprint disconnect in tf tree

asked 2019-11-29 03:13:24 -0500

bonoy0328 gravatar image

updated 2019-11-29 04:35:19 -0500

mgruhler gravatar image

I'm trying to publish tf tree.below is my code.

int main(int argc, char *argv[])
{
    ros::init(argc, argv, "robot_tf_broadcaster");
    ros::NodeHandle nh;

    static tf::TransformBroadcaster br;
    tf::Transform transform_lidar,transform_kinect,transform_odom,transform_odom2,transform_odom3,transform_odom4,transform_odom5,transform_odom1;
    transform_lidar.setOrigin(tf::Vector3(0,0,0.3));
    transform_lidar.setRotation(tf::Quaternion(0,0,0,1));  
    transform_odom.setOrigin(tf::Vector3(0,0,0.01));
    transform_odom.setRotation(tf::Quaternion(0,0,0,1));   
    transform_odom1.setOrigin(tf::Vector3(0,0,0.0));
    transform_odom1.setRotation(tf::Quaternion(0,0,0,1)); 
    transform_odom2.setOrigin(tf::Vector3(0,0,0.0));
    transform_odom2.setRotation(tf::Quaternion(0,0,0,1));  
    transform_odom3.setOrigin(tf::Vector3(0,0,0.0));
    transform_odom3.setRotation(tf::Quaternion(0,0,0,1));
    transform_odom4.setOrigin(tf::Vector3(0,0,0.0));
    transform_odom4.setRotation(tf::Quaternion(0,0,0,1));
    transform_odom5.setOrigin(tf::Vector3(0.13,0,0.2));
    transform_odom5.setRotation(tf::Quaternion(0,0,0,1));
    ros::Rate r(1000);
    while(nh.ok()){
        br.sendTransform(tf::StampedTransform(transform_lidar,ros::Time::now(),"base_link","base_laser_link"));
        br.sendTransform(tf::StampedTransform(transform_odom,ros::Time::now(),"base_footprint","base_link"));
        br.sendTransform(tf::StampedTransform(transform_odom1,ros::Time::now(),"camera_rgb_frame","base_footprint"));
        br.sendTransform(tf::StampedTransform(transform_odom2,ros::Time::now(),"camera_rgb_frame","camera_depth_frame"));
        br.sendTransform(tf::StampedTransform(transform_odom3,ros::Time::now(),"camera_depth_frame","camera_depth_optical_frame"));
        br.sendTransform(tf::StampedTransform(transform_odom4,ros::Time::now(),"camera_rgb_frame","camera_rgb_optical_frame"));         
        br.sendTransform(tf::StampedTransform(transform_odom5,ros::Time::now(),"base_link","camera_link"));
        r.sleep();
    }
    return 0;
}

I'm run the code, and run rosrun tf view_frame, I get the tf tree is no problem. but when I publish the odom to base_footprint transform in another file .all will be weird. I don't know what's wrong. can you hlep me.

edit retag flag offensive close merge delete

Comments

1

It might help to also show the code of the "[an]other file" as well as the ouput of the view_frames command and describe in more detail what "weird" means...

That being said: my guess is on incorrect specified parent->child relations. As the tf tree is actually this, a tree, there can ever only be a single parent for a child (a parent can have multiple children though). Most probably, you are having base_footprint twice as a child. it is once in your code, i.e. camera_rgb_frame->base_footprint. If you then publish odom->base_footprint this could explain the "weird" behaviour.

mgruhler gravatar image mgruhler  ( 2019-11-29 04:34:20 -0500 )edit