ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Small Confusion about TF

asked 2013-08-09 02:09:25 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

if I have a broadcaster like this:

void pub_odom::odom_callback(const nav_msgs::Odometry& odom) {

btVector3 Position;
btQuaternion Orientation;
tf::TransformBroadcaster odom_broadcaster_;
tf::StampedTransform odom_transform;

Position.setValue(odom.pose.pose.position.x,odom.pose.pose.position.y,odom.pose.pose.position.z);
Orientation.setW(odom.pose.pose.orientation.w);
Orientation.setX(odom.pose.pose.orientation.x);
Orientation.setY(odom.pose.pose.orientation.y);
Orientation.setZ(odom.pose.pose.orientation.z);

odom_transform.setOrigin(map_center);
odom_transform.setRotation(tf::Quaternion(tf::Vector3(0,0,1),-yaw_init));
odom_transform.stamp_ = odom.header.stamp;
odom_transform.child_frame_id_= "/odom";
odom_transform.frame_id_= "/center_map";
odom_broadcaster_.sendTransform(odom_transform);}

How do I visualise its publication on rviz and tf. Do i have to create something like in my launch file in order to visualise it:

<node pkg="tf" type="static_transform_publisher" name="tf_data" args="1.0 0.0 0.0 0.0 1.0 0.0 /odom /another_link 20" />

WHen I do it with this launch file I can visualise in tf the tranformation between /odom and /another_link and the transformation is based on args I have given in launch file. How do I get the publication based on the broadcaster and the callback function.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-08-09 10:16:29 -0500

BennyRe gravatar image

You can remove the static transform publisher from the launch file, if you want /center_map to be your center in rviz.

In your code do the following:

odom_transform.setOrigin(Position);
odom_transform.setRotation(Orientation);

In rviz select center_map as the fixed frame.

Hope this works.

edit flag offensive delete link more

Comments

so I removed the whole line <node pkg="tf" .................=""/> from my launch file. I also added the 2 lines that you mentioned into my code. But when I do rostopic list. It does not list tf as a topic now. Why does it not list tf as a topic. Similarly my view_frames return no tf data now. What should I do ?

micheal gravatar image micheal  ( 2013-08-10 06:17:02 -0500 )edit

Could you please update the code in your question, so I can check, if it's correct? Does your callback get called?

BennyRe gravatar image BennyRe  ( 2013-08-10 21:36:06 -0500 )edit
1

answered 2013-08-09 09:36:47 -0500

updated 2013-08-09 09:37:13 -0500

You can use view_frame to generate a pdf file and see the tf tree. In rviz you can visualise tf axes based on a fixed frame, commonly /map frame.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-08-09 02:09:25 -0500

Seen: 206 times

Last updated: Aug 09 '13