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

ROS2 - Transforming a non-frame pose with TF2?

asked 2022-02-15 02:38:48 -0600

Per Edwardsson gravatar image

updated 2022-02-15 22:58:05 -0600

I have a full transform tree going map -> odom -> base_link which works well for slamming with my robot. I would like to find a practical way to find a point which is x meters in _front_ of the robot. I could use the current orientation to figure out what "in front" means, then apply trigonometry to get the point in question.

Meanwhile, this type of calculation is done by TF2 all the time. It would make little sense to not use it for transforming poses between coordinate frames. However, it looks to me like TF2 can only transform _frames_, which means that I either need to create a frame for my goal pose, or do the above mentioned trigonometry.

What's the proper way of solving this problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-02-15 16:14:31 -0600

You can use the transform() API to transform a pose / point (and similar) from one from to another. So you could define a point 1m in front of a robot in base frame and use transform() to convert it to map coordinates -- or similar operations. This is pretty commonly used and I think is what you're looking for.

edit flag offensive delete link more


That looks like the solution for ros1, but I am using ros2. Perhaps I should have clarified in OP. Is there an equivalent for ros2?

Per Edwardsson gravatar image Per Edwardsson  ( 2022-02-15 22:57:42 -0600 )edit

In ROS 2 there's effectively the same API:

tfoote gravatar image tfoote  ( 2022-02-16 03:33:46 -0600 )edit

Yes, I don't even personally discriminate between the ROS 1 and ROS 2 documentation APIs in my development workflow because they're so similar. But Tully is correct and showed the ROS 2 versions.

stevemacenski gravatar image stevemacenski  ( 2022-02-16 14:01:47 -0600 )edit

Question Tools



Asked: 2022-02-15 02:38:48 -0600

Seen: 1,036 times

Last updated: Feb 15 '22