Skip to content
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

Merged
merged 5 commits into from
Nov 1, 2017
Merged

Refactor ConfigParser #236

merged 5 commits into from
Nov 1, 2017

Conversation

leokoppel
Copy link
Contributor

@leokoppel leokoppel commented Nov 1, 2017

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 use addParam, 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.

  • Remove huge enum and switch statements of types
  • Use templated Param class
  • Define enum for return codes instead of int

Pre-Merge Checklist:

  • Code is documented in doxygen format
  • Code has automated tests
  • Zero compiler warnings
  • Formatted with clang-format

- 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
@leokoppel leokoppel self-assigned this Nov 1, 2017
@leokoppel leokoppel requested review from chutsu and navganti November 1, 2017 00:58

*/
template <>
struct convert<cv::Mat> {
Copy link
Member

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?

Copy link
Contributor Author

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} {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move? typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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 &param);

/** Load yaml file at `config_file`. */
ConfigStatus load(std::string config_file);
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Member

@chutsu chutsu left a 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.

  1. It is should be installed by ROS by default
  2. The chances of any of us not using / having OpenCV on our deployment or dev machines is rather rare.
  3. 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.

@leokoppel
Copy link
Contributor Author

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.

@leokoppel leokoppel force-pushed the refactor_configparser branch from fbf617c to 3cceabc Compare November 1, 2017 03:34
@leokoppel leokoppel merged commit 2559f75 into master Nov 1, 2017
@leokoppel leokoppel deleted the refactor_configparser branch November 1, 2017 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants