Wiki
Optimization log
Existing English translations were reused. 1 current source blocks remain in Simplified Chinese, without triggering paid translation.
In practical applications, we rarely use RCLCPP_INFObecause the printing data overhead is too large, and industrial PC devices such as the Nvidia Jetson Xavier may not be able to handle it.
The figure below shows the printing overhead on a Raspberry Pi 4B:

Since we want to avoid such a large overhead and also want to view the printed data for debugging when necessary, we often useRCLCPP_DEBUGto print data, and print data only when necessary.
RCLCPP_DEBUG core role of
-
Debug-only : Outputs information only during the debugging phase, automatically silent in production environments
-
Performance optimization : Completely removes debug code through compilation options, with zero runtime overhead
-
Level control : Decoupled from other log levels (INFO/WARN/ERROR)

打印出来rclcpp_debug的方式:
Method 1:
ros2 run <package_name> <node_name> --ros-args --log-level debug
Method 2:
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='my_package',
executable='my_node',
name='my_node',
output='screen',
parameters=[],
arguments=['--ros-args', '--log-level', 'debug']
)
])
/opt/ros/humble/include/rcutils/rcutils/logging.hDefinition:
