Ask Your Question
10

ROS_INFO vs printf?

asked 2012-02-01 00:24:39 -0600

jlo gravatar image

updated 2014-01-28 17:11:14 -0600

ngrennan gravatar image

Hi there, I was wondering what the differences were between ROS_INFO and printf. In the tutorials it is referred as the equivalent to printf/cout. Any reason why it had to be implemented?

Cheers,

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
25

answered 2012-02-01 00:30:40 -0600

DimitriProsser gravatar image

updated 2012-02-01 00:44:18 -0600

ROS_INFO's syntax is the same as printf, but ROS_INFO is not printf. The advantage of the ROS logging system is that it provided a wide variety of useful features that printf does not.

For example, ROS_INFO is automatically timestamped for you. Second, it contains five logging levels that you can use. The advantage of these levels is that you can determine how much information you want to see at any given time. You can display only INFO-FATAL messages, or if you're debugging a problem, you can set the level to DEBUG and see all relevant debug messages.

ROS also automatically logs all messages that use ROS_INFO (and all other logging levels) to log files on the filesystem for you so that you can go back and analyze a test later.

EDIT:

See the wiki page here.

edit flag offensive delete link more

Comments

Thanks, very clarifying info! Any links where I can see how to use the different logging levels you mention?
jlo gravatar imagejlo ( 2012-02-01 00:42:17 -0600 )edit
Great explanation.
alfa_80 gravatar imagealfa_80 ( 2012-02-01 00:52:36 -0600 )edit

Plus python doesn't have printf, using ROS_INFO is better for x-language portability/readability, fwiw.

neuronet gravatar imageneuronet ( 2016-07-24 16:45:16 -0600 )edit

@jlohttp://wiki.ros.org/ROS/Tutorials/Usi... rqt_logger_level will let us see/monitoring events on the node and we can set with different logging levels

alienmon gravatar imagealienmon ( 2016-08-11 21:38:59 -0600 )edit

http://wiki.ros.org/rosconsole here is rosconsole doccumentation.

alienmon gravatar imagealienmon ( 2016-08-11 21:42:39 -0600 )edit
11

answered 2012-02-01 02:34:18 -0600

updated 2012-02-01 02:36:02 -0600

Another important difference is that ROS_INFO (and ROS_ERR,ROS_WARN, etc..)work as a distributed logging system. Messages are not just shown in the terminal but they are sent over the network to the rosout node. Then the rosout process can unify all the distributed logging messages for many purposes: filter data, using a unified GUI like rxconsole, etc.

edit flag offensive delete link more

Comments

As you said that messages are not shown in the terminal..But in general programming we use printf statements to see whether our code works properly or not.. I want to view the lines written inside ROS_INFO in the terminal, is there any procedure for it? Or how to view it through rosout?

RB gravatar imageRB ( 2014-04-29 21:03:49 -0600 )edit

"Messages are not just shown in the terminal..." - ROS_INFO messages are shown in BOTH the terminal and sent over the /rosout topic.

ahendrix gravatar imageahendrix ( 2015-04-02 13:10:15 -0600 )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

Stats

Asked: 2012-02-01 00:24:39 -0600

Seen: 26,223 times

Last updated: Feb 01 '12