Ask Your Question
0

How to correctly translate a pose along an axis?

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

Py gravatar image

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

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)

transformed_pose:

header:
    seq: 0
    stamp:
    secs: 0
    nsecs:         0
    frame_id: ''
pose:
    position:
       x: 0.4
       y: 0.0
       z: 0.0
    orientation:
       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

Comments

This answer might be helpful https://answers.ros.org/question/2223...

mohamed ahmed gravatar image mohamed ahmed  ( 2021-05-07 07:56:29 -0600 )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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

Py gravatar image

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

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

Seen: 123 times

Last updated: May 10 '21