Regarding print() in Ros2

Hi,

I use print() inside the code in ROS2 but I see it printed not same the order that I want.

I print() before send_request but terminal shows result of print() in the end

Why is it? And how does print() work in ROS2?

Thanks

Hi @NguyenDuyDuc ,

Yes, print() function does not work as expected in ROS2 based python scripts. This is a known fact (and not an issue). This is the way ROS2 framework for python is designed. Similarly, even in C++ programs, std::cout does not work sometimes, as expected, you will notice this when you start programming with C++.

You need to make use of the node’s logger variable to print as info or debug or into any other log level.

I hope this clarifies your doubt.

Regards,
Girish

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.