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

Math functions for geometry_msgs?

asked 2013-05-01 18:39:42 -0600

aswin gravatar image

Hi all, What is the best practice for doing simple math operations such as 'calculating 3D euclidian distance between two geometry_msgs::Points'?

I found a Linearmath folder in the 'tf' include for vectors, but did not find any related documentation.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-05-02 03:42:40 -0600

dornhege gravatar image

If it is really simple (like your example): Do it by hand, i.e. hypot(p1.x - p2.x,...).

If it is a little more advanced, or you might do more than 1 simple calculation: Convert the messages (which are just 'dumb' containers for data) to their respective tf data types. There are conversion functions like tf::pointMsgToTF for converting forth and back. The tf data types have all the geometry operations you'd expect for linear math.

edit flag offensive delete link more



Also note that the geometry stack includes nice functions for getting tf data into Eigen and KDL types. This can be useful if you need more complex math operations.

jarvisschultz gravatar image jarvisschultz  ( 2013-05-02 05:17:35 -0600 )edit

Question Tools


Asked: 2013-05-01 18:39:42 -0600

Seen: 4,581 times

Last updated: May 02 '13