ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Thu, 02 May 2013 05:17:35 -0500Math functions for geometry_msgs?https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/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.
Wed, 01 May 2013 18:39:42 -0500https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/Answer by dornhege for <p>Hi all,
What is the best practice for doing simple math operations such as 'calculating 3D euclidian distance between two geometry_msgs::Points'?</p>
<p>I found a Linearmath folder in the 'tf' include for vectors, but did not find any related documentation.</p>
https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/?answer=61980#post-id-61980If 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.Thu, 02 May 2013 03:42:40 -0500https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/?answer=61980#post-id-61980Comment by jarvisschultz for <p>If it is really simple (like your example): Do it by hand, i.e. hypot(p1.x - p2.x,...).</p>
<p>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.</p>
https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/?comment=61999#post-id-61999Also note that the [geometry stack](http://www.ros.org/wiki/geometry) includes nice functions for getting `tf` data into `Eigen` and `KDL` types. This can be useful if you need more complex math operations.Thu, 02 May 2013 05:17:35 -0500https://answers.ros.org/question/61957/math-functions-for-geometry_msgs/?comment=61999#post-id-61999