ROS_INFO_STREAM does not print

I am trying to use ROS_INFO_STREAM inside an illegible try ... catch, but I only have top level output

Here's the minimum code group:

void failure()
{
    try
    {
      // throw std::length_error
      std::string("abc").substr(10);                    
    }
    catch (...)
    {
      ROS_ERROR_STREAM("ROS failure()");          // print OK
      std::cout << "cout failure()" << std::endl; // print OK
      throw; // re-throw the exception
    }
}


int main()
{
  try
  {
    ROS_ERROR_STREAM("ROS calling"); // print OK
    failure(); // will throw
  }
  catch (...)
  {
    ROS_ERROR_STREAM("ROS call function"); // <-- NO print
    std::cout << "cout call function" << std::endl; // print OK
  }

  return 0;
}

exit:

ROS calling
ROS failure()
cout failure()
cout call function

I assume that ROS_ERROR_STREAM looks buffered, but it should not be an error output.

I run ros groovy

+4
source share
1 answer

All macros in rosconsole stop working when it ros::shutdown()was called somewhere in the ROS node.

I can imagine that something like this happens to you: the catch block is basically probably reached after an error that automatically calls the function ros::shutdown().

, , ROS, , , , :

std::cout << "[ INFO] [" << ros::Time::now() << "]: main catch" << std::endl;
+2

Source: https://habr.com/ru/post/1608763/


All Articles