ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to correctly translate a pose along an axis?

asked 2021-04-23 10:39:20 -0500

Py gravatar image

updated 2021-05-07 07:56:57 -0500

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.

edit retag flag offensive close merge delete


This answer might be helpful

mohamed ahmed gravatar image mohamed ahmed  ( 2021-05-07 07:56:29 -0500 )edit

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?

Py gravatar image Py  ( 2021-05-07 13:53:20 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-05-10 09:23:56 -0500

Py gravatar image

updated 2021-05-10 10:06:30 -0500

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)
edit flag offensive delete link more

Question Tools



Asked: 2021-04-23 10:39:20 -0500

Seen: 486 times

Last updated: May 10 '21