Ask Your Question
0

Is there a way to use rospy.info with complex messages?

asked 2021-01-31 03:10:02 -0500

Kansai gravatar image

When I search about rospy.loginfo all I get is examples with topics that publish string messages.

What happen with complex messages? If I have

def a_callback(msg): rospy.loginfo("The messages is ",msg)

and msg is a complex message, is there a way to make it work? or should I do something like

rospy.loginfo("the message id is %d",msg.header.id)

edit retag flag offensive close merge delete

Comments

Could you please mark the question as answered by ticking the checkmark (✓) to the left of the answer if you feel it has been answered? Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-08 02:14:11 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-01-31 05:17:04 -0500

gvdhoorn gravatar image

updated 2021-01-31 05:20:35 -0500

What happen with complex messages?

you'll see The message is followed by whatever is the __str__(..)/__repr__(..) representation of the message.

In rospy, this will print the (almost) YAML formatted version of the message contents.


Edit: and just to clarify: rospy.log*(..) doesn't do anything special with your logstrings. So anything which is a str, or can be converted to a str can be passed to it.

That makes your question more about "can 'complex messages' be converted to a str" than a question about rospy.log*(..).

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

2 followers

Stats

Asked: 2021-01-31 03:10:02 -0500

Seen: 40 times

Last updated: Jan 31