tf2 - Do child frames share time stamps?

asked 2020-04-26 03:47:39 -0600

connor.p gravatar image

I've created a simple cube using interactive markers which appears as you would expect in RVIZ. I then added a new frame where the z-axis oscillates (giving the impression of an up-down movement). I called this new frame moving_frame. The code for which is:

void frameCallback(const ros::TimerEvent& time){
    static uint32_t counter = 0;
    static tf2_ros::TransformBroadcaster br;

    geometry_msgs::TransformStamped t;

    t.header.stamp = ros::Time::now();
    t.header.frame_id = "base_link";
    t.child_frame_id = "moving_frame";

    t.transform.translation.x = 0.0;
    t.transform.translation.y = 0.0;
    t.transform.translation.z = sin(float(counter)/140.0);

    tf2::Quaternion q;
    q.setRPY(0, 0, 0);

    t.transform.rotation.x = q.x();
    t.transform.rotation.y = q.y();
    t.transform.rotation.z = q.z();
    t.transform.rotation.w = q.w();



However, when I change the frame_id of my interactive marker, the cube no longer appears in RVIZ. An extract of the code looks like so:

visualization_msgs::InteractiveMarker int_marker;

int_marker.header.frame_id = "moving_frame";

int_marker.pose.position.x = 2;
int_marker.pose.position.y = 2;
int_marker.pose.position.z = 0;

int_marker.scale = 1;

int_marker.header.stamp = ros::Time::now(); = "my_marker";

I managed to rectify this error by removing the time stamp from the interactive marker (more luck than knowledge). So I was wondering if when connecting to a child_frame are the time stamps shared? If so, why when I include a time stamp (like the code above), does it result in the cube no longer appearing?

edit retag flag offensive close merge delete



Not an answer, but: the timestamp is associated with the transform, not the frame/link. I'm not sure your question can be answered.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-26 03:59:07 -0600 )edit

Hi gvdhoorn, thank you for taking the time to comment on my question. Out of curiosity why do you believe my question can't be answered? Surely this must be explainable considering only the time stamp is causing the problem?

connor.p gravatar image connor.p  ( 2020-04-26 04:19:39 -0600 )edit

Your question title is "Do child frames share time stamps?", that's what I was commenting on.

As I wrote: the timestamps say something about the transform, not about the (child) frames.

You may want to change your question title to something which more directly describes the issue you are encountering, instead of suggesting a possible cause, just to avoid an xy-problem.

As to your problem: it's just a guess, but it could be that by specifying now() as the stamp for the interactive marker, you're asking TF to transform it to a frame which doesn't exist yet (ie: if now() is newer than what the cache contains).

gvdhoorn gravatar image gvdhoorn  ( 2020-04-26 04:28:39 -0600 )edit

You're jumping to conclusions about how things are structured which is why your question is "unanswerable". Frames don't have timestamps to share. There's a large set of tutorials to help you understand the transforms that I'd recommend you go through to see if you can understand things better with fewer moving parts. Otherwise to get more help we'll need a fully reproducible example to be able to help you effectively.

tfoote gravatar image tfoote  ( 2020-04-27 18:24:25 -0600 )edit