Ask Your Question
0

How to use tf.transformPose of tf mpdule?

asked 2020-04-14 08:44:21 -0600

kane_choigo gravatar image

Hello, I'm using ROS melodic of Ubuntu 18.04.

I recently heard that tf module has the special class function which transforms a specific pose into the pose of another specific frame.

I tried calling tf.TransformerROS.transformPose, but I've just gotten only this error:

"/sensor_frame" passed to lookupTransform argument target_frame does not exist

. Of course, I double-checked that /sensor_frame was practically running. (I tried

$ rosrun tf tf_echo

and also checked it on rviz tool.)

Below is my code,

import rospy
import tf
from geometry_msgs.msg import PoseStamped


def talker():
  pub = rospy.Publisher('/that', PoseStamped, queue_size = 10)
  rate = rospy.Rate(10)

   # goaler = tf.TransformerROS()
   goaler = tf.TransformListener()

   while not rospy.is_shutdown():
      goal = PoseStamped()
      goal.pose.position.x = 5.0
      goal.pose.position.y = 5.0

      # ret = goaler.transformPose("lidar_sensor_link", goal)
      ret = goaler.transformPose("/sonar2_link", goal)

      pub.publish(ret)
      rate.sleep()



 if __name__ == '__main__':
   rospy.init_node('pracd')

    try:
        talker()
    except rospy.ROSInterruptException:
        pass

(Just so you know, I referred to here)

I'm not familiar with tf, so I 'm suffered from fixing..

What should I do to coordinate transformation works?

Thanks inadvance :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-04-14 13:49:19 -0600

tfoote gravatar image

To start off with you should use tf2 not tf. tf has been deprecated for several years now and tf2 has a superset of it's functionality. https://wiki.ros.org/tf2

And to understand how it works there are tutorials: https://wiki.ros.org/tf2/Tutorials

It looks like you're using the API correctly but you likely need to make sure that the rest of your system is setup correctly to support the coordinate frames that you intend to query.

For completeness there are tf tutorials as well. But if you're just getting started you should really move forward.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-14 08:44:21 -0600

Seen: 164 times

Last updated: Apr 14