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

Types of input for get_logger in ros2 RCLCPP_INFO

asked 2022-04-14 10:29:11 -0600

Flash gravatar image

updated 2022-04-14 10:38:07 -0600

Hi,
I was trying to find what types of input can be provided for

RCLCPP_INFO(get_logger(), "data: %*", data)

I had used %s for string kind of output but was wondering if it can take any other types of data. While looking over some codes I saw the use of %g not sure what it represents.
Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-04-14 20:08:54 -0600

aprotyas gravatar image

The second argument in the logging macros is a format specification, i.e. a pointer to a null-terminated multibyte string specifying how to interpret the data. As such, you can use any standard format specifier accepted by printf. Here's a small reference list: https://en.cppreference.com/w/cpp/io/...

Also, from the same link: %g converts floating-point number to decimal or decimal exponent notation depending on the value and the precision.

edit flag offensive delete link more

Comments

Can I know which second argument you are talking about?

Flash gravatar image Flash  ( 2022-04-15 10:18:11 -0600 )edit

In RCLCPP_INFO(get_logger(), "data: %s", "message") the "data: %s" const character buffer would correspond to the second argument.

aprotyas gravatar image aprotyas  ( 2022-04-15 11:01:04 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-04-14 10:29:11 -0600

Seen: 2,057 times

Last updated: Apr 14 '22