0
$\begingroup$

Rosanswers logo

hello,

I'm using Ubuntu 14.04 and ROS Indigo

I used the following block of code to publish the transformation of base_link frame and odom frame:

geometry_msgs::TransformStamped odom_trans;
    odom_trans.header.stamp = current_time;
    odom_trans.header.frame_id = "odom";
    odom_trans.child_frame_id = "base_link";

    odom_trans.transform.translation.x = x;
    odom_trans.transform.translation.y = y;
    odom_trans.transform.translation.z = 0.0;
    odom_trans.transform.rotation = odom_quat;

    //send the transform
    odom_broadcaster.sendTransform(odom_trans);

Also, I used this launch file to publish the other frames:

<launch>
<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0 0 1 0 0 0 1 base_link camera_link 100" />
</launch>

When the robot start moving I run rviz and it shows the odom frame moving, but the base_link and camera_link are fixed in their initial position. I think I missed something but I don't know what is it.

UPDATE:

  1. current_time is set inside the loop while(nodehandle.ok()) and is set to current_time = ros::Time::now();

  2. odom_broadcaster is created outside the loop and at the beginning of the main as tf::TransformBroadcaster odom_broadcaster;

  3. This is running live

  4. When I run rosrun tf tf_echo odom base_link it shows values like:

    At time 1428335473.731

    • Translation: [-0.338, 1.148, 0.000]
    • Rotation: in Quaternion [0.000, 0.000, 0.295, 0.955] in RPY [0.000, -0.000, 0.600] At time 1428335474.787
    • Translation: [-1.613, 3.059, 0.000]
    • Rotation: in Quaternion [0.000, 0.000, 0.223, 0.975] in RPY [0.000, -0.000, 0.449]
  5. This is my tf tree:

tf tree

Also I have this transformation in the launch file: <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0 0 1 0 0 0 1 base_link camera_link 100" />


Originally posted by nouf on ROS Answers with karma: 71 on 2015-04-05

Post score: 2


Original comments

Comment by Tom Moore on 2015-04-06:
When do you set the current_time variable, and with what value? Also, where are you creating odom_broadcaster? Are you running this live or against a bag file? What happens if you run rosrun tf tf_echo odom base_link?

Comment by nouf on 2015-04-06:
please find the update in the question

Comment by l0g1x on 2015-04-06:
what does roswtf tell you?

Comment by Tom Moore on 2015-04-06:
Wait, are you expecting odom and base_link to move with one another? odom is a world-fixed frame, and base_link is attached to the robot. As your robot moves through the world, they will not remain "with" one another in rviz.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Did you solve? Be sure in your code to update all frames with the most recent time stamp. I mean, every loop you should be sure that the broadcast information is updated:

odom_trans.header.stamp = ros::Time::now();

From the tutorial you see that that line of code is inside a loop. maybe you forgot to update all the frames for the camera and so on... I hope I helped you.

Regards


Originally posted by Andromeda with karma: 893 on 2015-04-25

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.