Ask Your Question
0

How to read data from "/rosout" topic using c++ node.

asked 2019-10-11 04:38:57 -0500

kjitender469 gravatar image

I want to write a c++ node which subscribe the topic /rosout read data from it and print the extracted data on terminal using ROS_INFO().

edit retag flag offensive close merge delete

Comments

1

You just need a subscriber to the topic to read the data it contains. You can follow example here

Choco93 gravatar imageChoco93 ( 2019-10-11 04:59:20 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-11 05:54:46 -0500

Hello,

ROS_INFO() will display the message in the terminal, but ROS_INFO() will also send a message to /rosout. If you create a node that subscribe to /rosout and use ROS_INFO(), you will write an infinite loop because :

1 . Node receive message from /rosout

2 . Node print with ROS_INFO()

3 . ROS_INFO() Send a message to /rosout

4 . Go back to 1

For a simple example of how to do a subscriber, you can subscribe to /rosout and simply use std::cout for displaying the message (or your favorite logging system that doesn't use /rosout).

If you want to extract Warning, Error or Fatal level message, you can use a message filter, or just discarding message with logger level less than warning in the beginning of the callback function.

edit flag offensive delete link more

Comments

Ok. I have written a node using C++ but i am unable to extract "msg" field data from it. The type of rosout is rosmsgs_graph/Log. I want to extract the data from "msg" field and convert it into string.

kjitender469 gravatar imagekjitender469 ( 2019-10-11 07:24:11 -0500 )edit

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: 2019-10-11 04:38:57 -0500

Seen: 25 times

Last updated: Oct 11