ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
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

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

Question Tools

2 followers

Stats

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

Seen: 105 times

Last updated: Jan 31 '21