ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

RCUTILS_SET_ERROR_MSG and RMW_SET_ERROR_MSG output and behavior

asked 2020-04-08 16:35:00 -0500

jeremya gravatar image

According to doxygen and this line, RCUTILS_SET_ERROR_MSG() should produce output if rcutils_reset_error wasn't called and "this library" (assuming RCL) was built with the RCUTILS_REPORT_ERROR_HANDLING_ERRORS flag set. I see that the build flag is set here and here.

Since there are many of the RCUTILS_SET_ERROR_MSG (and RMW_SET_ERROR_MSG) calls in RCL and RMW, I expect to see some of these outputs to stderr, stdout, or a log file somewhere on occasion.

  1. What am I missing to turn these prints on and where to do they actually go?
  2. Do I need to build ROS2 from source to enable this output with some other flags set or would the precompiled binaries have this capability innately?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-24 08:32:57 -0500

hidmic gravatar image

Partially reproducing what I've written elsewhere, rcutils error handling is somewhat similar to POSIX errno based error handling. There's a global error state, that in this case is populated with an arbitrary string, and functions let calling code know there was an error in some way -- often using a well-known numeric return code, but sometimes it may be something else. From then on, it is up to calling code to decide on what should be done with that (string) error state.

Thus,

  1. *_SET_ERROR_MSG macros are not conditionally-compilable print or logging macros. They set an error state. Where, when, how and even if that error state is eventually made visible is entirely up to client code up in the stack. RCUTILS_REPORT_ERROR_HANDLING_ERRORS purpose is not to turn some of these macros into prints, but to avoid masking errors by printing the error state that is about to be overwritten in the hypothetical case in which client code does poor error handling (i.e. it reports errors with error handling itself).

  2. Question is based on an invalid assumption/expectation.

Hope this clarifies things a bit.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-04-08 16:35:00 -0500

Seen: 262 times

Last updated: Apr 24 '20