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

How to transform Vector3 with tf::Transform?

asked 2020-03-25 02:38:18 -0600

pauljurczak gravatar image

updated 2020-03-25 02:54:50 -0600

I have a position Vector3 pWorld in WORLD coordinate system and I have a tf::Transform t from WORLD to TURTLE coordinate system. I would like to get a transformed position Vector3 pTurtle, which is pWorld in TURTLE coordinate system. What is a simple way of doing it?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-03-25 03:54:37 -0600

bob-ROS gravatar image

Similar example earlier. I assume you can replace your tf::transform with tf::transformStamped retrieved from lookupTransform .

tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tf2_listener(tfBuffer);
geometry_msgs::TransformStamped your_transform; 

your_transform = tfBuffer.lookupTransform("TURTLE", "WORLD", ros::Time(0), ros::Duration(1.0) );
geometry_msgs::Point your_point;
tf2::doTransform(your_point, your_point, your_transform);
edit flag offensive delete link more


Is there a tf equivalent of tf2::doTransform? I'm having some issues with tf2.

pauljurczak gravatar image pauljurczak  ( 2020-03-25 04:01:27 -0600 )edit

Yes there is See

transformPoint (const std::string &target_frame, const geometry_msgs::PointStamped &stamped_in, geometry_msgs::PointStamped &stamped_out)

Create a PointStamped message and insert your position. In the header: put the frame you are currently in, the stamp = ros::Time::now() and I think you can ignore the seq value in the header.

bob-ROS gravatar image bob-ROS  ( 2020-03-25 04:13:46 -0600 )edit

answered 2020-04-28 12:42:15 -0600

Lost Monkey 5 gravatar image

An issue ticket was opened for a tf2::doTransfrom() that I think will answer your question.

edit flag offensive delete link more

Question Tools



Asked: 2020-03-25 02:38:18 -0600

Seen: 1,030 times

Last updated: Mar 25 '20