Open henrik7264 opened 5 years ago
This is a fragment how I did logging in the rxros_talker (still not merged):
rxcpp::observable<>::interval (std::chrono::milliseconds (1000))
| map ([&](int i)٠
{ return mk_msg(hello + std::to_string(i)); })
| tap ([](const std_msgs::String& msg)٠
{ ROS_INFO ("%s", msg.data.c_str()); })
| publish_to_topic<std_msgs::String> ("/chatter", 1000);
As you can see tap
does almost what you want. It is probably very hard to do more -- you want to have access to the current message when formatting the string. So the only thing we can save is to remove ROS_INFO call, perhaps a simple wrapper around tap
for rxros_info
and the associated siblings of ROS_INFO could be added, to save this one call.
But it is probably not a very high priority. I would not argue against it though. Seems like a nice-to-have.
It should be possible to write something similar to the following code:
It is important to provide a consistent and simple logging framework. It should be equally easy to log in a sequence of operator as well as outside. A proposed framework should be presented before implementation.