How to listen to static transform from robot state publisher using the tf2 TransformListener? [closed]

asked 2018-02-15 17:36:07 -0600

johnyang gravatar image

updated 2018-02-15 20:44:16 -0600

I have set up a robot state publisher with my own robot, and I implemented a listener to obtain the TF message by using tf2_ros's TransformListener. I can obtain the /tf information correctly by using the lookupTransform() and allFramesAsString(). However, I can't figure out a way to obtain the /tf_static (as I believe this is a latched topic which doesn't really get published in the same way as /tf. I read the source code and I just couldn't see how I can extract information still if the "message_subscriber_tf_static_" is not even being triggered.

If using rostopic echo /tf_static, you can definitely see that it has been published but the transform_listener's message_subscriber_tf_static_ has never triggered to call static_subscription_callback().

<node name="robot_state_publisher_arm" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
</node>

I am also wondering that, instead of using launch file to setup robot_state_publisher, will implementing it in C++ with calling publishFixedTransforms() in a loop solve the problem? (i.e. implementing out own publisher routine for static tf.)

Note: tf_echo seems to work with robot_state_publisher but not with tf2 transform listener.

Example listener code I am using which is from the tutorial page (I have a static transform between link0 and world which is described in my urdf file.):

tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer,nh_arm,false);
try{
    geometry_msgs::TransformStamped transformStamped = tfBuffer.lookupTransform("link0", "world",ros::Time(0));
    ROS_INFO_STREAM("link1=\n" << transformStamped.transform);
}
catch (tf2::TransformException &ex) {
    ROS_WARN("%s",ex.what());
    // ros::Duration(1.0).sleep();
}

My question is how to actually get "static transform" (like fixed joint described in the urdf file). There is no documentation how to get it. There are plenty of example how to get the tf transform but not the static one. The constructor side is just one example where I was trying out different namespace and thread setting. I also tried compiled from source code and made relative changes to see which functions are actually being called.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2019-04-08 00:32:36.875201

Comments

For reference repost of: https://github.com/ros/geometry2/issu...@johnyang please clarify what you're actually trying to do by editing this with possibly some code samples, and answers to the questions in my reply. You are stating that things aren't working, but not stating how to reproduce.

tfoote gravatar image tfoote  ( 2018-02-15 17:48:08 -0600 )edit

There's a guide to how to ask good questions at http://wiki.ros.org/Support Please read that and update your question with more information.

tfoote gravatar image tfoote  ( 2018-02-15 17:48:31 -0600 )edit

I updated the question with some example code but those are just the same as from the tutorial of getting a normal tf but I want to get the static tf. I just need to see one example how to do it.

johnyang gravatar image johnyang  ( 2018-02-15 20:31:44 -0600 )edit
3

My question is how to actually get "static transform" (like fixed joint described in the urdf file).

there is no difference between static transforms or other transforms. tf2_ros::TransformListener will subscribe to both /tf and /tf_static and will automatically merge the msgs for you.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-16 01:44:22 -0600 )edit

But when I tried to call lookupTransform() with "world", it can't find the link. Do you have some example code to help me out here?

johnyang gravatar image johnyang  ( 2018-02-18 17:02:29 -0600 )edit

But when I tried to call lookupTransform() with "world", it can't find the link

then it could be that there just isn't a transform for it (at the time you're trying to look it up).

I have set up a robot state publisher with my own robot

are you reusing robot_state_publisher, or have you ..

gvdhoorn gravatar image gvdhoorn  ( 2018-02-19 01:52:35 -0600 )edit

.. written something yourself?

Do you have some example code to help me out here?

no, not besides what is already in the tutorials. That has always worked for me.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-19 01:52:47 -0600 )edit

Weird. Are you using ROS jade? I am using robot_state_publisher. I can get most of the TF correctly except the static tf part to the world.

johnyang gravatar image johnyang  ( 2018-02-27 21:31:41 -0600 )edit