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

Transforming in combined tree

asked 2019-03-08 19:54:17 -0500

sisko gravatar image

updated 2019-03-09 03:54:58 -0500

I have a task of using a static ur5 manipulator to detect and point at a mobile turtlebot. I am a beginner and I'm told transforms is the solution I want. (Please comment if you disagree).

I have a ur5 and a turtlebot3 spawned into a an empty gazebo world.

I have a static transform publisher, shown below, in my launch file which I use to combine the tf trees of both robots.

<node pkg='tf2_ros' type='static_transform_publisher' name='ur5_turtlebot3_transform' args='0 0 0 0 0 0 1 world odom'/>

So the merged tf tree is as follows: image description

The green bordered section on the right of the image is the turtlebot3 tf tree. Everything else is the ur5 tf tree. As my static transform code shows, I attached the turtlebot tree to the ur5 tree at the world node.

Further down the ur5 tree I highlighted in red the wrist_3_link node which is the node of origin for my attempted transform. The destination node is the base_footprint node, the second and last node on the turtlebot3 side of the tree.

However, my can_transform attempts at return 0 (false). So as you would expect lookup_transforms errors:

def __init__(self):

    # declarations
    self.robot = moveit_commander.RobotCommander()
    self.scene = moveit_commander.PlanningSceneInterface()
    self.manipulator = moveit_commander.MoveGroupCommander('ur5_bot')

    self.tf_buffer = tf2_ros.Buffer()
    self.tf_listener = tf2_ros.TransformListener(self.tf_buffer)

    try:
        # transform_stamped = tf_buffer.lookup_transform('wrist_3_link', 'base_footprint', rospy.Time())
        transform_stamped = self.tf_buffer.can_transform('wrist_3_link', 'base_footprint', rospy.Time())
        rospy.loginfo(transform_stamped)
    except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException) as e:
        rospy.logerr(e)

And, just to test, I tried a can_transform between nodes entirely on the ur5 side of the tree, i:e base_link to world, but still the result was false.

I'm not sure what I'm missing and/or doing wrong. I would appreciate some help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-03-09 06:48:27 -0500

You're 99% of the way there, there is just one detail of how transform listeners work you're missing.

You cannot create a transform listener then query it for transforms straight away, you need to give it a second or more otherwise it will fail to find a transform as in your case. To fix this you can add a one second sleep after you create the listener object then this should start working.

The reason is that the tf listeners needs to build up a buffer of tf messages before it is aware of all the transforms and is able to correctly answer tf queries.

Hope this helps.

edit flag offensive delete link more

Comments

Thank you buddy ;-)

sisko gravatar image sisko  ( 2019-03-09 08:30:40 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-03-08 19:54:17 -0500

Seen: 357 times

Last updated: Mar 09 '19