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

Simplest way to obtain a transformation matrix and multiply it with a 3D point

asked 2023-07-21 21:49:12 -0500

dlam0002@student.monash.edu gravatar image

Hi, I'm new to ROS. In C++, would like the obtain the x,y,z coordinates of the point (star) with respect to Frame A. What is the simplest and quickest way to obtain the transformation matrix from Frame B to Frame A and then multiply it with the coordinates of the point with respect to Frame B? I can't attach images so I've linked a url of the image: https://ibb.co/mNhwMMy

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-22 12:23:02 -0500

danzimmerman gravatar image

TF2 is a good option for frame lookups, and definitely what you want to use if you want to share coordinate frame information with your larger ROS system:

http://wiki.ros.org/tf2 https://docs.ros.org/en/iron/Tutorial...

There you can query in Frame A the pose of an object published in Frame B using Frame A's name. There's an explicit tutorial here:

https://foxglove.dev/blog/using-ros2-...

In C++ in general, not just ROS, I generally use Eigen for linear algebra, and it has built-in transform types that handle geometric transformation math; see this Eigen Geometry Tutorial. In particular, an Eigen::Isometry3d represents a rigid transformation. Eigen might be most useful if you have a lot of code-local coordinate frame calculations that aren't needed outside of your node. There's negligible boilerplate for a one-off calculation, and it's nice to have around.

There are many other good options out there for C++ transformation math in geometry processing, computer vision, and robotics libraries, and other linear algebra libraries, but both TF2 Eigen are straightforward to add to your ROS C++ projects, since they ship with base ROS.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-21 21:49:12 -0500

Seen: 67 times

Last updated: Jul 22 '23