Rclcpp: [rclcpp_lifecycle] issue a warning if publishing on a not active publisher

Created on 6 Sep 2018  路  8Comments  路  Source: ros2/rclcpp

Feature request

Feature description

Since a publisher can be active or not is should be useful for debug purpose to issue a WARN when publishing on a not active publisher

Implementation considerations

Add a RCLCPP_WARN at Line 78:
https://github.com/ros2/rclcpp/blob/4d67a8671b55b28a6ae63697310a11632a888ed4/rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_publisher.hpp#L78

enhancement good first issue

All 8 comments

I believe the warning makes sense. Would you consider opening a PR for this?

I'm adding the warning message, but I cannot understand how to do it.
Normally I use RCLCPP_WARN, but I'm not inside a node, so it cannot be called, right?

You can use the rcutils/logging_macros.h to get non-node specific logging macros.
There are some examples in the test: https://github.com/ros2/rcutils/blob/master/test/test_logging_macros.cpp

It gives you macros such as RCUTILS_LOG_DEBUG_NAMED ... I am not sure whether you can use the RCLCPP macros without a node logger. @dhood can you help out here?

To use rclcpp logging macros you do need a rclcpp::Logger, the demos repository contains some examples of passing a node logger to a function as well as creating a logger with rclcpp::get_logger and using it for logging.

@Myzhar any updates on this?

@Karsten1987 I'm sorry, but I'm not working on ROS2 now, I had to move to ROS1.
I try to find a bit of time to complete this enhancement

I did a PR with the solution, which matches the one proposed by @Myzhar

in #574

Hope it helps

Was this page helpful?
0 / 5 - 0 ratings