I am using multiple turtlebot3 robots in my simulation with gazebo. The differential time plugin publishes a transform between the `odom` frame and the `base_footprint` frame. I also have a plugin which publishes the ground truth pose of the turtlebot3 `libgazebo_ros_p3d.so`.
I want to generate transformations between multiple turtlebot3 robots and to do this I have a seperate node which broadcasts transform between the `base_link` frame and the `world` frame. The problem is that the `base_link` to `world` transformations are published with the `sim_time` as I intend but for some reason the transformations between the `base_footprint` and `odom` frame are published with my computers clock time.
Because of this I cannot generate transformations between the `odom` frame and the `world` frame.
Heres what I would like my tf tree to be:
-------------------- world --------------------
tb1/base_link tb2/base_link tb3/base_link
| | |
tb1/base_footprint tb2/base_footprint tb3/base_footprint
| | |
tb1/odom tb2/odom tb3/odom
Heres the snippets of code:
The main launch file:
The gazebo plugins in the turtlebot's xacro file:
cmd_vel odom odom world true base_footprint false true true false 30 wheel_left_joint wheel_right_joint 0.287 0.066 1 10 na true 50.0 base_link ground_truth_pose 0.01 world 0 0 0 0 0 0
Turtlebot3.launch
`base_link` to `world` tf broadcaster:
#!/usr/bin/env python
import rospy
import sys
import tf
from nav_msgs.msg import Odometry
def update_tf(data):
transform_from = "{}/base_footprint".format(ns)
transform_to = "world"
pos = data.pose.pose.position
ori = data.pose.pose.orientation
orientation = [ori.x, ori.y, ori.z, ori.w]
position = [pos.x, pos.y, pos.z]
br = tf.TransformBroadcaster()
print rospy.Time.now()
br.sendTransform(position, orientation, rospy.Time.now(), transform_from, transform_to)
if __name__ == '__main__':
ns = sys.argv[1]
rospy.init_node("tf_broadcaster_{}".format(ns.split('_')[1]))
pose_subscriber = rospy.Subscriber("{}/ground_truth_pose".format(ns), Odometry, update_tf)
rospy.spin()
Here's the output from the `/tf` topic:
transforms:
-
header:
seq: 0
stamp:
secs: 2764768896
nsecs: 32752
frame_id: "burger_2/odom"
child_frame_id: "burger_2/base_footprint"
transform:
translation:
x: 2.20744910982
y: 2.01895292219
z: -0.000612418868214
rotation:
x: -0.000874178201541
y: -0.000801260462534
z: 0.999653654558
w: -0.0262900118476
---
transforms:
-
header:
seq: 0
stamp:
secs: 102756
nsecs: 880000000
frame_id: "world"
child_frame_id: "burger_1/base_footprint"
transform:
translation:
x: 1.32845899318
y: 0.92220015314
z: -0.0104010663862
rotation:
x: 0.000706580835481
y: 0.000460995693433
z: 0.0407422461322
w: -0.9991693338
---
`rosrun tf view_frams` gives the fowwing output:
Warning: TF_OLD_DATA ignoring data from the past for frame burger_2/base_footprint at time 2.76477e+09 according to authority /gazebo
Possible reasons are listed at http://wiki.ros.org/tf/Errors%20explained
at line 277 in /tmp/binarydeb/ros-kinetic-tf2-0.5.18/src/buffer_core.cpp
Warning: TF_OLD_DATA ignoring data from the past for frame burger_2/base_footprint at time 2.76477e+09 according to authority /gazebo
Possible reasons are listed at http://wiki.ros.org/tf/Errors%20explained
at line 277 in /tmp/binarydeb/ros-kinetic-tf2-0.5.18/src/buffer_core.cpp
`roswtf` ouput:
Loaded plugin tf.tfwtf
No package or stack in context
================================================================================
Static checks summary:
No errors or warnings
================================================================================
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules
running tf checks, this will take a second...
... tf checks complete
Online checks summary:
Found 2 warning(s).
Warnings are things that may be just fine, but are sometimes at fault
WARNING The following node subscriptions are unconnected:
* /gazebo:
* /gazebo/set_model_state
* /gazebo/set_link_state
WARNING Received out-of-date/future transforms:
* receiving transform from [/tf_broadcaster_1] that differed from ROS time by -1.38s
* receiving transform from [/gazebo] that differed from ROS time by 4001227263.39s
I even tried passing `` in the turtlebot's launch file but in vain ...
Any help is appreciated, thanks in advance
↧