I'm pretty new to ROS but I was manipulating a custom message that was made up of geometry_msgs/Point
and geometry_msgs/Vector3
messages. When I printed out the message I noticed that both the Point
and the Vector3
had the same 3 attributes (x
, y
, and z
) and this made me curious because it seemed redundant... right?
Upon further digging in the source code, it turns out the Point
and the Vector3
are exactly the same. They're both composed of a float x
, float y
, and a float z
.
But after reading the docs, it seems like there IS a difference between these two messages. The docs mention that a Point should be used if the user wants to apply a translation whereas a Vector3 should be used to only represent a direction (and magnitude I guess?).
Since the two messages are defined exactly the same, I reckon if I could apply a translation to a Point
I could also apply a translation to the Vector3
. Is there a difference I'm not seeing between the Point
and Vector3
that isn't their name?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With