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

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 image jlo  ( 2012-02-01 00:42:17 -0600 )edit
Great explanation.
alfa_80 gravatar image alfa_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 image neuronet  ( 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 image alienmon  ( 2016-08-11 21:38:59 -0600 )edit

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

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

I have some existing code that I want to port into ROS2 environment. It contains some printf() lines. Will those printf() prints be visible on the terminal? Ragards, Bojan.

bojankoce gravatar image bojankoce  ( 2021-06-18 06:58:26 -0600 )edit

Question Tools

Stats

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

Seen: 35,187 times

Last updated: Feb 01 '12