Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can transform points in base_link frame to odom frame using TF as follows

listener = tf.TransformListener()
listener.waitForTransform("/base_link", "/odom", rospy.Time(0),rospy.Duration(4.0))
laser_point=PointStamped()
laser_point.header.frame_id = "base_link"
laser_point.header.stamp =rospy.Time(0)
laser_point.point.x=1.0
laser_point.point.y=1.0
laser_point.point.z=0.0
p=listener.transformPoint("odom",laser_point)

You can transform points in base_link frame to odom frame using TF as follows

listener = tf.TransformListener()
listener.waitForTransform("/base_link", "/odom", rospy.Time(0),rospy.Duration(4.0))
laser_point=PointStamped()
laser_point.header.frame_id = "base_link"
laser_point.header.stamp =rospy.Time(0)
laser_point.point.x=1.0
laser_point.point.y=1.0
laser_point.point.z=0.0
p=listener.transformPoint("odom",laser_point)

Output look likes

[ INFO] [1498858767.555667233]: Current: [X= 0.105044,Y= -0.020144,Theta= -22.776758]

header: 
  seq: 0
  stamp: 
    secs: 0
    nsecs:         0
  frame_id: odom
point: 
  x: 1.41420562607
  y: 0.514734522986
  z: 1.0
header: 
  seq: 0
  stamp: 
    secs: 0
    nsecs:         0
  frame_id: odom
point: 
  x: 1.41420562607
  y: 0.514734522986
  z: 1.0

You can transform points in base_link frame to odom frame using TF as follows

listener = tf.TransformListener()
listener.waitForTransform("/base_link", "/odom", rospy.Time(0),rospy.Duration(4.0))
laser_point=PointStamped()
laser_point.header.frame_id = "base_link"
laser_point.header.stamp =rospy.Time(0)
laser_point.point.x=1.0
laser_point.point.y=1.0
laser_point.point.z=0.0
p=listener.transformPoint("odom",laser_point)

Output look likes

[ INFO] [1498858767.555667233]: Current: [X= 0.105044,Y= -0.020144,Theta= -22.776758]

header: 
  seq: 0
  stamp: 
    secs: 0
    nsecs:         0
  frame_id: odom
point: 
  x: 1.41420562607
  y: 0.514734522986
  z: 1.0
header: 
  seq: 0
  stamp: 
    secs: 0
    nsecs:         0
  frame_id: odom
point: 
  x: 1.41420562607
  y: 0.514734522986
  z: 1.0