ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What is the difference between the usage of %i, %d,%f in ROS_INFO("")?

asked 2019-07-05 00:08:56 -0500

Dickson gravatar image

I see a lot of usage of like

ROS_INFO("%d")

ROS_INFO("%i")

ROS_INFO("%f")

used, is there a difference in the usage of them? If so, what are the differences. Is there like a webpage where this has been explained?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2019-07-05 00:54:42 -0500

updated 2019-07-05 00:56:11 -0500

ROS_INFO and other ROS log functions follow the same format as the standard C printf function. You can find more information here http://wiki.ros.org/rosconsole and http://www.cplusplus.com/reference/cs...

The ones you mention:

int decimal_integer_value = 5;
float float_pont_value = 10.0f;
ROS_INFO("%d", decimal_integer_value);
ROS_INFO("%i", decimal_integer_value);
ROS_INFO("%f", float_point_value);

Would output:

 5
 5
 10.0

%d and %i are equivalent and use to print decimal integer values, %f is used to print floating point numbers"

edit flag offensive delete link more

Comments

Thank you very much (:

Dickson gravatar image Dickson  ( 2019-07-08 03:52:34 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-07-05 00:08:56 -0500

Seen: 8,550 times

Last updated: Jul 05 '19