ROS2编程基础课程--日志

网友投稿 479 2022-05-30

课程补充参考资料:https://download.csdn.net/download/zhangrelay/11751608

Logging and logger configuration

日志记录和日志记录器配置

Table of Contents 目录

Overview 概叙

Logger concepts 日志记录器概念

Logging usage 日志记录用法

Logger configuration 日志记录器配置

Command line configuration of the default severity level 默认严重性级别的命令行配置

Programmatic configuration of individual loggers 单个记录器的编程配置

Console output configuration 控制台输出配置

Overview 概述

The logging functionality currently supported is: 目前支持的日志记录功能是:

Client libraries (rclcpp and rclpy) using a common logging library to provide:

客户端库(rclcpp和rclpy)使用通用日志记录库来提供:

Log calls with a variety of filters.

使用各种过滤器记录调用。

Hierarchy of loggers.

记录器的层次结构。

Loggers associated with nodes that automatically use the node’s name and namespace.

与自动使用节点名称和命名空间的节点关联的记录器。

Console output.

控制台输出。

File output and functionality akin to rosout for remote consumption of messages is forthcoming.

文件输出和功能类似于用于远程消费消息的rosout即将发布。

Programmatic configuration of logger levels.

记录器级别的编程配置。

Launch-time configuration of the default logger level is supported; config files and external configuration at run-time is forthcoming.

支持默认记录器级别的启动时配置; 即将在运行时配置文件和外部配置。

[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim

[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

[WARN] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=11.112445, y=5.544445])

[WARN] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=11.120889, y=5.544445])

Logger concepts 日志记录器概念

Log messages have a severity level associated with them: DEBUG, INFO, WARN, ERROR or FATAL, in ascending order.

日志消息与其相关联的严重性级别:DEBUG,INFO,WARN,ERROR或者FATAL,按升序排列。

A logger will only process log messages with severity at or higher than a specified level chosen for the logger.

记录器仅处理严重性等于或高于为日志记录器选择的指定级别的日志消息。

Each node (in rclcpp and rclpy) has a logger associated with it that automatically includes the node’s name and namespace. If the node’s name is externally remapped to something other than what is defined in the source code, it will be reflected in the logger name. Non-node loggers can also be created that use a specific name.

每个节点(如 rclcpp和rclpy)都有一个与之关联的记录器,它自动包含节点的名称和名称空间。如果节点的名称从外部重新映射到源代码中定义的名称以外的其他名称,则它将反映在记录器名称中。还可以创建使用特定名称的非节点记录器。

Logger names represent a hierarchy. If the level of a logger named “abc.def” is unset, it will defer to the level of its parent named “abc”, and if that level is also unset, the default logger level will be used. When the level of logger “abc” is changed, all of its descendants (e.g. “abc.def”, “abc.ghi.jkl”) will have their level impacted unless their level has been explicitly set.

日志记录器名称表示层次结构。如果未设置名为“abc.def”的记录器的级别,它将推迟到其名为“abc”的父级别,如果该级别也未设置,则将使用默认记录器级别。当记录器“abc”的级别改变时,其所有后代(例如“abc.def”,“abc.ghi.jkl”)将对其级别产生影响,除非已明确设置其级别。

Logging usage 日志记录用法

In C++: 在C ++中:

See the logging demo for example usage.

有关示例用法,请参考日志记录演示

See the rclcpp documentation for an extensive list of functionality.

有关功能的详尽列表,请参考rclcpp文档。

In Python: 在Python中:

See the rclpy examples for example usage of a node’s logger.

有关节点记录器的示例用法,请参考rclpy示例。

See the rclpy tests for example usage of keyword arguments (e.g. skip_first, once).

有关关键字参数的使用示例,请参考rclpy测试(例如skip_first,once)。

Logger configuration 日志记录器配置

Command line configuration of the default severity level

默认严重性级别的命令行配置

As of the Bouncy ROS 2 release, the default severity level for loggers can be configured from the command line with the following, for example (the level string is not case sensitive):

从Bouncy ROS 2及以后的版本开始,可以从命令行配置记录器的默认严重性级别,例如:

(级别字符串不区分大小写)

ros2 run demo_nodes_cpp listener _log_level:=debug

This will affect all loggers that have not explicitly been configured to use a particular severity level. Configuration of specific loggers from the command line is forthcoming.

这将影响未明确配置为使用特定严重性级别的所有记录器。即将从命令行配置特定记录器。

Programmatic configuration of individual loggers

各个记录器的编程配置

Logger configuration is still under development. For now, the severity level of individual loggers can be configured programmatically with, e.g.:

记录器配置仍在开发中。目前,可以通过编程方式配置各个记录器的严重性级别,例如:

In C++: 在C ++中:

rcutils_logging_set_logger_level("logger_name", RCUTILS_LOG_SEVERITY_DEBUG);

In Python: 在Python中:

logger.set_level(rclpy.logging.LoggingSeverity.DEBUG)

rclpy.logging.set_logger_level('logger_name', rclpy.logging.LoggingSeverity.DEBUG)

The logging demo provides an example of manually exposing a service so that loggers can be configured externally; in the future we expect runtime configuration capabilities of loggers to be exposed automatically.

所述日志记录演示提供的手动开发服务,使得记录器可从外部配置; 在未来,希望记录器的运行时配置功能能够自动公开。

Console output configuration

控制台输出配置

By default, console output will be formatted to include the message severity, logger name, and the message. Information such as the file name, function name and line number of the log call are also available. Custom console output format can be configured with the RCUTILS_CONSOLE_OUTPUT_FORMAT environment variable: see the rcutils documentation for details. As rclpy and rclcpp both use rcutils for logging, this will effect all Python and C++ nodes.

默认情况下,控制台输出将被格式化为包括消息严重性,记录器名称和消息。还可以使用日志调用的文件名,函数名和行号等信息。可以使用RCUTILS_CONSOLE_OUTPUT_FORMAT环境变量配置自定义控制台输出格式:有关详细信息,请参考rcutils文档。由于rclpy和rclcpp都使用rcutils了日志记录,这将影响所有的Python和C ++节点。

Features Status 功能状态

The features listed below are available in the current ROS 2 release. Unless otherwise specified, the features are available for all supported platforms (Ubuntu 18.04, OS X 10.12.x, Windows 10), DDS implementations (eProsima Fast RTPS, RTI Connext and ADLINK Opensplice) and programming language client libraries (C++ and Python). For planned future development, see the Roadmap.

下面列出的功能可在当前的ROS 2版本中找到。除非另有说明,否则这些功能适用于所有支持的平台(Ubuntu 18.04,OS X 10.12.x,Windows 10),DDS实现版本(eProsima Fast RTPS、RTI Connext和ADLINK Opensplice)和编程语言客户端库(C ++和Python)。有关未来发展的计划,请参考路线图。

Functionality 功能

Link 链接

Fine print

Discovery, transport and serialization over DDS 通过DDS进行发现,传输和序列化

Article

Support for

multiple DDS implementations

, chosen at runtime

支持在运行时选择的

多个DDS实现

Tutorials

Currently eProsima Fast RTPS, RTI Connext and ADLINK OpenSplice are fully supported.

Common core client library that is wrapped by language-specific libraries

由特定语言的库封装的公共核心客户端库

Details

Publish/subscribe over topics

发布/订阅主题

Sample code

,

Article

Clients and services

客户端和服务端

Sample code

Set/retrieve parameters

设置/检索参数

Sample code

ROS 1 - ROS 2 communication bridge

ROS 1 - ROS 2通信桥接

Tutorial

Available for topics and services, not yet available for actions.

Quality of service settings for handling non-ideal networks

处理非理想网络的服务质量设置

Demo

Inter- and intra-process communication using the same API

使用相同API的进程间和进程内通信

Demo

Currently only in C++.

Composition of node components at compile-, link- or dlopen-time

编译、链接或dlopen时间节点组件的组成

Demo

Currently only in C++.

Support for nodes with managed lifecycles

ROS2编程基础课程--日志

支持具有托管生命周期的节点

Demo

Currently only in C++.

DDS-Security support

DDS-Security支持

Demo

Command-line introspection tools using an extensible framework

使用可扩展框架的命令行自检工具

Tutorial

Launch system for coordinating multiple nodes

启动系统以协调多个节点

Tutorial

Namespace support for nodes and topics

命名空间支持节点和主题

Article

Static remapping of ROS names

静态重新映射ROS名称

Tutorial

Demos of an all-ROS 2 mobile robot

全ROS 2移动机器人的演示

Demo

Preliminary support for real-time code

初步支持实时代码

Demo

,

demo

Linux only. Not available for Fast RTPS.

Preliminary support for “bare-metal” microcontrollers

对“bare-meta”微控制器的初步支持

Wiki

Beside features of the platform the most impact of ROS comes from its available packages. The following are a few high profile packages which are available in the latest release:

除了平台的功能外,ROS的最大影响来自其可用的包。以下是最新版本中提供的一些高级别功能的软件包:

gazebo_ros_pkgs

image_transport

navigation2

rosbag2

RQt

RViz2

Python 控制台

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:【并发技术14】线程同步工具Semaphore的使用
下一篇:136_Java_SpringMVC_HandlerInterceptor_拦截器
相关文章

 发表评论

暂时没有评论,来抢沙发吧~