Ask Your Question
0

Help a isloated and helpless learner in tf

asked 2015-08-12 22:22:46 -0500

unicornair gravatar image

Hi,everybody I'm a chinese student,because of the greatwall firewall,I can not get enough and explicit documentations except for wiki.ros.I'm so sorry to interrupt you for asking these silly questions,if you would share your valuable time to dispel my doubts,I am deeply grateful. Here are the baffle puzzled me: 1.what is the "lookupTransform" method below,what type of date does it return? I can not find any descriptions against it. 2.I'm fairly puzzled with traslation and transformation,they belong to the same description in chinese.And i get trouble with euler and quaternion,I don't understand what the arguments x,y,z,w refer to,I'm hoping for a nice boy to solve my problems,if you'd like to introduce more msg in ros detailed,nice of you!!!!^_^

The following is the unsolved code:

listener = tf.TransformListener()
 rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')

turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)

rate = rospy.Rate(10.0)
while not rospy.is_shutdown():
    try:
        (trans,rot) = listener.lookupTransform('/turtle2', '/turtle1', rospy.Time(0))
    except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
        continue

    angular = 4 * math.atan2(trans[1], trans[0])
    linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
    cmd = geometry_msgs.msg.Twist()
    cmd.linear.x = linear
    cmd.angular.z = angular
    turtle_vel.publish(cmd)

    rate.sleep()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-08-13 03:27:02 -0500

MarkyMark2012 gravatar image

This should help

Mark

lookupTransform

lookupTransform() is a lower level method which returns the transform between two coordinate frames. This method is the core functionality of the tf library, however most often the transform* methods will be used by the end user. This methods is designed to be used within transform*() methods.

The direction of the transform returned will be from the target_frame to the source_frame. Which if applied to data, will transform data in the source_frame into the target_frame. See tf/CoordinateFrameConventions#Transform_Direction

This may throw any tf exception

Basic API

Toggle line numbers

1 void tf::TransformListener::lookupTransform (const std::string &target_frame, const std::string &source_frame, const ros::Time &time, StampedTransform &transform) const

Fill transform with the transform from source_frame to target_frame at time.

Advanced API

Toggle line numbers

1 void tf::TransformListener::lookupTransform (const std::string &target_frame, const ros::Time &target_time, const std::string &source_frame, const ros::Time &source_time, const std::string &fixed_frame, StampedTransform &transform) const

Fill transform with the transform from source_frame to fixed_frame at source_time, chained with the transform from fixed_frame to target_frame at target_time
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: 2015-08-12 22:22:46 -0500

Seen: 95 times

Last updated: Aug 13 '15