-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace fprintf with ROS 2 logging #16
Comments
Should the parse do any writing to log files? As a suggestion, perhaps it could throw a parsing exception? The caller can then decide if the error should be logged or silent. FYI I am resolving a similar issue over in ros2_controls URDF Transmissions parser (PR 182) and I figured I'd come over here to see how it was done and get a feel for precedence. Perhaps find an existing parsing exception class. @Karsten1987 suggested I remove the rclcpp dependency since I am only using it for logging in favor of rclutils logging directly. For now, I am going to switch the Transmission parsing class to throw runtime_error exception and there is also a simple convenience function that parses urdf Transmissions using that class that will catch the exception and send to rclutils logging (which rclcpp logging is based on). Eventually I'd like to integrate Transmissions parsing as part of this urdf module. Thoughts? If you would like I can replace the fprintf calls with rclutils calls since I am doing the same thing over there. Unless you use other parts of rclcpp it reduces the dependency footprint. |
As it stands, this package doesn't depend on either |
Agreed - I would use the rcutils API for this package. As far as I can tell that only requires including the macros and using them. #include <rcutils/logging_macros.h>
// ...
RCUTILS_LOG_WARN_NAMED(
"my_package", "Blah Bla Blah [%s] failed", some_str.c_str());
// ...
@guru-florida You might find inspiration in SDFormat's Errors class. The APIs |
Related PR #37 |
The
Model
class communicates error messages by callingfprintf()
urdf/urdf/src/model.cpp
Line 70 in 533de85
This should instead use ROS 2's logging functionality. This might mean passing in a logger instance to the class.
See also:
#13 (review)
#13 (comment)
The text was updated successfully, but these errors were encountered: