0
$\begingroup$

Rosanswers logo

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()

Originally posted by unicornair on ROS Answers with karma: 7 on 2015-08-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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

Originally posted by MarkyMark2012 with karma: 1834 on 2015-08-13

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.