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.