how to broadcast a tf frame? [closed]

asked 2014-09-09 10:47:15 -0500

choog gravatar image

Hello,

I have a tf frame named /base_link which is part of the turtlebot 2. I am trying to take the information that the /base_link frame contains such as its position(xyz) and its orientation(rpy) and broadcast this info to a new tf frame. The reason why I am doing this is because I could not tf_remap to work. So I am thinking that the next step is to create a broadcaster that sends out this info as a new name. I am highly confused of what info goes where. Below is the code that I have so far. I grabbed this info from the tf tutorials available on the wiki page.

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>


void poseCallback( ){ //don't know what to pass through
  static tf::TransformBroadcaster br;
  tf::Transform transform;
  transform.setOrigin( tf::Vector3(msg->x, msg->y, 0.0) );
  transform.setRotation( tf::Quaternion(msg->theta, 0, 0) );
  br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "base_footprint", "base_link")); //don't know what to pass through
}

int main(int argc, char** argv){
  ros::init(argc, argv, "my_tf_broadcaster");
  ros::NodeHandle node;
  ros::Subscriber sub = node.subscribe("move_base/pose", 10, &poseCallback);

  ros::spin();
  return 0;
};
edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by choog
close date 2014-09-25 21:53:55.327004

Comments

1

I'm not sure with what you mean with "pass through", but it seems that you are trying a hack to do something that should be solved properly.

dornhege gravatar imagedornhege ( 2014-09-09 11:09:05 -0500 )edit
2

what is move_base/pose data type. What exactly you are trying to do.

bvbdort gravatar imagebvbdort ( 2014-09-09 11:14:13 -0500 )edit

What I am trying to do is really complicated it would take to long to explain. For simple purposes, I have a /tf frame that been received from another turtlebot through a foreign relay. Now I have a program that is going to compare information on both of the /tf topics. However, the /tf header id's

choog gravatar imagechoog ( 2014-09-09 11:46:31 -0500 )edit

are not being resolved such as /tf and /leader/tf. In other words the node that I am having read this info is such as transform("base_link" , "leader/base_link", .......) I tried to remap the topic received by the foreign relay to be /leader/tf but that does not work

choog gravatar imagechoog ( 2014-09-09 11:48:20 -0500 )edit

So Now I am trying to create a broadcaster that changes the name to "leader/base_link"

choog gravatar imagechoog ( 2014-09-09 11:48:52 -0500 )edit

move_base/pose is simply the position of the turtlebot in reference to it's base_link

choog gravatar imagechoog ( 2014-09-09 11:50:05 -0500 )edit

Hi, you have to check frameid in callback and broadcast transform with the frame names you want. but i guess pose is geometry_msgs::Pose type and it doesn't have header to check frameid. Still need info on your question.

bvbdort gravatar imagebvbdort ( 2014-09-09 12:59:57 -0500 )edit

I will update question in a few hours. I am working on something.

choog gravatar imagechoog ( 2014-09-09 22:11:36 -0500 )edit