Do rostest test nodes publish to rosout?
Hello all,
Some background. I am new to writing unit tests in gtests/rostest. So a lot of this might be just me unable to find that awesome link which will clear everything up. Anyway, here it goes:
My node under test: This node is only subscribing to /rosout_agg
. Think of this as some sort of diagnostics node.
My test scenario: I want to publish several series of messages to /rosout
from my test cases and see how my diagnostics node responds to this. So I was thinking I will just use the log statements such as ROS_INFO
, ROS_WARN
and ROS_ERROR
to publish my test case messages onto /rosout
. I am not directly publishing to this topic. Rather just using the log statements.
My rostest
file looks like follows:
<?xml version="1.0"?>
<launch>
<node pkg="diagnostics" type="diagnostics" name="diagnostics_node" output="screen"/>
<test test-name="diagnostics_test_node" pkg="diagnostics" type="diagnostics_test_node"/>
</launch>
- When I run this file using
rostest
, my diagnostics node is not picking up any messages from/rosout_agg
. The subscriber callback in my node under test never gets called. - Note that, when I run my
diagnostics_test_node
as just a gtest and my diagnostics node separately, everything is working as expected.
So the question I have is, do the test nodes that rostest
starts automatically start a rosout
as well (The XML file does not seem to have any mention of rosout)? What happens to the messages created by the log statements in the test node in this case? Should I be directly publishing to /rosout
instead of using log statements? Any other ideas on how I should be testing a stream of messages from /rosout_agg
?
Please let me know if I can expand on my question!
IIRC the log level of a test is set to warn, so ros info and ros debug messages will not get written to rosout
Thanks for the comment! Yes info and debug wont be shown unless a test node logger level is set otherwise. But I’m not seeing warns and errors be caught even though I see all my test messages on screen. In other words warn and error are seen on screen but there is no way to check if rosout is picking them.