Difference between tf2::convert and tf2::to/fromMsg
Hey there, I recently started using ROS and TF2 and i usually find myself the need to transform between tf types and message types. What is the proper way, using convert or from/toMsg! Are there any good explanation when one should favour one over the other? Any good examples to look through? Thanks for your time!
The
convert
function can convert an object to another one (ROS message or not). The functionstoMSG
andfromMSG
will be used by theconvert
function to convert/create a ROS message to/from any type (of tf2 data type)@Delb: why did you post that as a comment?
I wasn't sure it fully answers the question, I can delete the comment and post as an answer it if you prefer
Thanks for the reply! Yes, i am aware of that, as described by the documentation. Just a bit of clarification. Why not always call the
convert
function since it can handle all the types ( ROS or not). Are there any red flags on why not use it instead oftoMsg
andfromMsg
?Well it can handle all types IF there are the corresponding
toMSG
andforMSG
methods defined for the type and if inconvert(a,b)
,a
andb
are not already messages.