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

What is the difference between Vector3 and point message? Do they contain the same data values?

asked 2016-06-03 14:56:48 -0600

umair gravatar image

I made a tf listener which gets a transform of type tf::StampedTransform between two given frames. Then this transform is converted to ros message type from ros tf type via the function tf::transformStampedTFToMsg(). It gives a message of type geometry_msgs::TransformStamped which contains Vector3 translation and not point translation.

What I need ultimately is the position of child frame origin w.r.t. the parent frame origin. And I am intending to use the information provided in the Vector3 translation as it is, assuming that it contains exact values for the translation required to move from the parent frame origin to the child frame origin. Please correct me if I am wrong.

I got confused after reading out from this link: that Vector3 only provides direction??? So does it mean that the magnitude values are just raw values? If not, then they should be the same as in point translation, no?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-04 17:45:05 -0600

johnconn gravatar image

updated 2020-02-05 03:34:08 -0600

gvdhoorn gravatar image

This question was answered here. Quoting to preserve the answer in case the link ever goes down:

Even though Point and Vector3 have the same content, the tf2 library checks the type of message and acts on it differently, depending on whether it is a Point or a Vector3.

Ultimately, this was a decision made by the developer to highlight the conceptual distinction between a Point (a point in space which cannot be rotated), and a Vector3 (a direction which has no definite location in space but which can be rotated).

The developer did not have to make this distinction, and in fact many physics libraries use a single Vector3 datatype to handle directions, points, velocities, etc.

As with Colors (red, green, blue) and Dates (year, month, day) and many other things which can be represented as a Vector3, ultimately it comes down to the need to draw artificial distinctions to make the code easier to understand for users and other programmers.

From the documentation in the vector message

This represents a vector in free space. It is only meant to represent a direction. Therefore, it does not make sense to apply a translation to it (e.g., when applying a generic rigid transformation to a Vector3, tf2 will only apply the rotation). If you want your data to be translatable too, use the geometry_msgs/Point message instead.

edit flag offensive delete link more



I feel it's important to draw attention to this part of the answer on SO:

The developer did not have to make this distinction, and in fact many physics libraries use a single Vector3 datatype to handle directions, points, velocities, etc.

while technically there is certainly no difference in the syntax between a point and a vector3 (although only in a 3D space), the semantics are vastly different. That is what is important here, and that's the reason why we have different message types in ROS.

It's not about form, it's about meaning.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-05 03:35:26 -0600 )edit

Question Tools

1 follower


Asked: 2016-06-03 14:56:48 -0600

Seen: 1,504 times

Last updated: Feb 05 '20