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

Difference between tf2::convert and tf2::to/fromMsg

asked 2018-10-02 13:49:25 -0500

xkaraman gravatar image

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!

edit retag flag offensive close merge delete

Comments

The convert function can convert an object to another one (ROS message or not). The functions toMSG and fromMSG will be used by the convert function to convert/create a ROS message to/from any type (of tf2 data type)

Delb gravatar image Delb  ( 2018-10-03 02:16:48 -0500 )edit

@Delb: why did you post that as a comment?

gvdhoorn gravatar image gvdhoorn  ( 2018-10-03 02:52:57 -0500 )edit

I wasn't sure it fully answers the question, I can delete the comment and post as an answer it if you prefer

Delb gravatar image Delb  ( 2018-10-03 03:02:02 -0500 )edit

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 of toMsg and fromMsg?

xkaraman gravatar image xkaraman  ( 2018-10-03 05:11:40 -0500 )edit
1

Well it can handle all types IF there are the corresponding toMSG and forMSG methods defined for the type and if in convert(a,b), a and b are not already messages.

Delb gravatar image Delb  ( 2018-10-03 06:15:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-10-03 04:47:09 -0500

Delb gravatar image

The convert function can convert an object to another one (ROS message or not). The functions toMSG and fromMSG will be used by the convert function to convert/create a ROS message to/from any type (of tf2 data type).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-02 13:49:25 -0500

Seen: 721 times

Last updated: Oct 03 '18