0
$\begingroup$

Rosanswers logo

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?


Originally posted by Per Edwardsson on ROS Answers with karma: 501 on 2022-02-15

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

http://docs.ros.org/en/noetic/api/tf2_ros/html/c++/classtf2__ros_1_1BufferInterface.html

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.


Originally posted by stevemacenski with karma: 8272 on 2022-02-15

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Per Edwardsson on 2022-02-15:
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?

Comment by tfoote on 2022-02-16:
In ROS 2 there's effectively the same API: https://docs.ros.org/en/ros2_packages/rolling/api/tf2_ros/generated/classtf2__ros_1_1BufferInterface.html

Comment by stevemacenski on 2022-02-16:
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.

$\endgroup$
1
  • $\begingroup$ Is the transform() API consistent with tf2_geometry_msgs e.g., do_transform_pose from here? $\endgroup$
    – roshambo
    Commented Dec 14, 2023 at 15:44

Your Answer

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