[Documentation] [TitleIndex] [WordIndex

Contents

  1. Logging

New in 0.2.0

Logging

Like any ROS node, you can log messages at the appropriate verbosity level. ROSserial forwards the string to the standard ROS network and outputs to rosout and to its log file.

If you try to log information before the device has connected to ROS, the logged information will be lost.

Keep in mind that for low memory systems, this kind of logging is very expensive. You need to store the string in memory before you send it. For more memory thrifty logging, try defining a custom message type with exactly the information you need sent over. You can then view your program's status by observing it using rostopic echo.

   1 //create your node
   2 ros::NodeHandle nh;
   3 
   4 //wait until you are actually connected
   5 while (!nh.connected() ){
   6     nh.spinOnce();
   7 }
   8 
   9 //Now you can send all of the statements you want
  10 //to be logged at the appropriate verbosity level
  11   nh.logdebug("Debug Statement");
  12   nh.loginfo("Program info");
  13   nh.logwarn("Warnings.");
  14   nh.logerror("Errors..");
  15   nh.logfatal("Fatalities!");

2022-05-28 12:58