0

i am working with ROS and my task is to migrate existing Projects from ros1 to ros2. In ros1 stream functions like

ROS_INFO_STREAM(String << variable << ...) 

exist but not in ros2, because they are not implemented yet in the rclcpp. My idea is to write a function in c++ that works with these operators and works like std::cout. But i really don't know how to implement a function like this.

Does anyone have an idea or approach?

Solution: A possible solution is to define a macro like this

#define ROS_INFO_STREAM(logger, _msgStream) std::stringstream stream_buffer; stream_buffer << _msgStream; ROS_INFO(logger, stream_buffer.str().c_str());

in a separate headerfile and include it wherever it is needed.

4

0 回答 0