Ask Your Question
0

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

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

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 imageDelb ( 2018-10-03 02:16:48 -0600 )edit

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

gvdhoorn gravatar imagegvdhoorn ( 2018-10-03 02:52:57 -0600 )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 imageDelb ( 2018-10-03 03:02:02 -0600 )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 imagexkaraman ( 2018-10-03 05:11:40 -0600 )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 imageDelb ( 2018-10-03 06:15:25 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 247 times

Last updated: Oct 03 '18