Base_link frame is not connected to odom frame
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:
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" />
When do you set the
current_time
variable, and with what value? Also, where are you creatingodom_broadcaster
? Are you running this live or against a bag file? What happens if you runrosrun tf tf_echo odom base_link
?please find the update in the question
what does
roswtf
tell you?Wait, are you expecting
odom
andbase_link
to move with one another?odom
is a world-fixed frame, andbase_link
is attached to the robot. As your robot moves through the world, they will not remain "with" one another inrviz
.