Rosanswers logo

I have a pose of my robot base_link in the map frame. I'd like to translate this 0.2 m along the robot x-axis so the point is in front of the robot. To do this I've tried the following but all it seems to do is give the transformed_pose the same position in the x-axis of my transforms x-axis translation. How might I fix this?

transform = TransformStamped()
transform.transform.translation.x = 0.2
transformed_pose = tf2_geometry_msgs.do_transform_pose(pose, transform)


    seq: 0
    secs: 0
    nsecs:         0
    frame_id: ''
       x: 0.4
       y: 0.0
       z: 0.0
       x: 0.0
       y: 0.0
       z: 0.5
       w: 0.0

I've tried to troubleshoot this issue in this question, which may be a useful reference.

Originally posted by Py on ROS Answers with karma: 501 on 2021-04-23

Post score: 0

Original comments

Comment by mohamed ahmed on 2021-05-07:
This answer might be helpful https://answers.ros.org/question/222306/transform-a-pose-to-another-frame-with-tf2-in-python/

Comment by Py on 2021-05-07:
I use this method to get the pose of my robot base_link in the map frame actually and it works great. How would I adapt this method to get the pose of the robot base_link + 0.2 m in the x-axis in the map frame?


1 Answer 1


Rosanswers logo

After some playing around, the following code achieved me to translate my pose along the x-axis.

transform = self.tf_buffer.lookup_transform(frame, required_position, rospy.Time(0), rospy.Duration(1))
initial_pose = PoseStamped()
initial_pose.pose.position.x = 0.2
translated_pose = tf2_geometry_msgs.do_transform_pose(initial_pose, transform)

Originally posted by Py with karma: 501 on 2021-05-10

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

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