-
Notifications
You must be signed in to change notification settings - Fork 28
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
Refactor ConfigParser #236
Conversation
- Use a templated ConfigParam instead of a switch statement and "type" enum - Take advantage of yaml-cpps existing `convert` mechanism - Still need to implement `convert` for Eigen and CV matrices
Explicitly instantiate the functions that were there before
|
||
*/ | ||
template <> | ||
struct convert<cv::Mat> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not supposed to be in the vision module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate PR #237
/** Base class representing a parameter to be parsed in the yaml file */ | ||
struct ConfigParamBase { | ||
ConfigParamBase(std::string key, bool optional) | ||
: key{std::move(key)}, optional{optional} {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why move? typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just hurts my head.
ConfigStatus loadParam(const ConfigParamBase ¶m); | ||
|
||
/** Load yaml file at `config_file`. */ | ||
ConfigStatus load(std::string config_file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::string &
maybe, I know I haven't been putting const
everywhere but maybe we should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. I'm not sure why you didn't want to have the ability to load cv::Mat
here?
I think more explanation is needed to say why wave_utils
shouldn't have OpenCV as a dependency considering.
- It is should be installed by ROS by default
- The chances of any of us not using / having OpenCV on our deployment or dev machines is rather rare.
- Lastly,
cv::Mat
is very stable, and it is very unlikely to change in the future.
If you can update the issue about this problem I think it would be useful for future reference.
OK, I added some reasoning to the issue. One of our projects does currently have an issue with opencv which I can tell you about offline. |
fbf617c
to
3cceabc
Compare
Prereq for #234
Refactor ConfigParser. The primary motivation is to allow defining parsing functions in other modules, so wave_utils does not depend on OpenCV, or any future classes we want to parse.
Basically this is a wrapper around yaml-cpp's
convert
mechanism. However, by request I kept the interface to ConfigParser the same, so other classes still useaddParam
,load(file)
, etc.Note that despite the templates, the parsing functions for Matrix, etc. are still compiled into the library. Only the same types are still supported.
Pre-Merge Checklist:
clang-format