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

Feature/dynamic configs #25

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Feature/dynamic configs #25

wants to merge 22 commits into from

Conversation

Schmluk
Copy link
Collaborator

@Schmluk Schmluk commented Aug 18, 2024

  • Initial implementation of dynamic configs and dynamic config servers.
  • Also adds a ROS server to set configs via topics (not via params for now, although we could think of this too)
  • Add utests
  • Add demo with two GUIs to set configs (Plain YAML and specialized fields, although experimental)
  • Add docs
  • Minor refactor and cleanup of settings. This will be breaking interfaces though (should be easy to fix if used)

@Schmluk Schmluk requested a review from nathanhhughes August 18, 2024 20:24
@Schmluk Schmluk force-pushed the feature/dynamic_configs branch from c82f6d7 to ebac5c1 Compare August 18, 2024 20:25
@Schmluk Schmluk force-pushed the feature/dynamic_configs branch from c6ef9d9 to 27f2f79 Compare September 9, 2024 20:49
Copy link
Collaborator

@nathanhhughes nathanhhughes left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for putting this together! The general structure seems very intuitive!

We'll need to coordinate though on when we actually merge this given the changes to the settings struct (it'll break Hydra). Alternatively we could split this into two PRs (one with the settings, one with the dynamic configs) but I think that's more work than it's worth at this point

@@ -40,7 +40,7 @@
#include <typeinfo>
#include <vector>

#include "config_utilities/internal/meta_data.h"
#include <yaml-cpp/yaml.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

(minor) This is maybe my fault, but dataToString should probably live elsewhere (and this file could probably just be standard library includes and the gnu demangling)

*/
template <typename ConfigT>
struct DynamicConfig {
using Callback = std::function<void()>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

(minor) I feel like I often find myself writing callbacks that are something like

[&]() {
  const auto& config = dynamic_config_.get();  
  // do stuff with config
}

which is slightly simpler as

[&](const DynamicConfig<ConfigT>& dynamic_config) {
  const auto& config = dynamic_config.get();
}

Comment on lines 119 to 141
/**
* @brief Parse a single value to the yaml node.
* @param value The value to parse.
* @param error Optional: Where to store the error message if conversion fails.
*/
template <typename T>
static YAML::Node toYaml(const T& value, std::string* error = nullptr) {
YAML::Node node;
std::string err;
try {
node = toYamlImpl("tmp", value, err);
} catch (const std::exception& e) {
err = std::string(e.what());
}
if (!err.empty()) {
if (error) {
*error = err;
}
return YAML::Node(YAML::NodeType::Null);
}
return node["tmp"];
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

It took me a while to parse why this overload existed, mostly because of the "tmp" namespace. I think it might make more sense to have toYamlImpl not namespace the returned node and have the previous toYaml version handle namespacing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed! I've been meaning to clean this up but didn't want to touch everything, should be better now 👍

@Schmluk Schmluk force-pushed the feature/dynamic_configs branch from 99d4887 to 222a82a Compare November 17, 2024 22:52
@Schmluk
Copy link
Collaborator Author

Schmluk commented Nov 17, 2024

Many thanks for the pointers @nathanhhughes! Agreed, probably good to time this. I'm not in a rush with this and also wanted to expose which modules are registered, for the main use of easier visualization switches (as Marcus correctly noted, currently it's a bit hard to figure out which colorizer goes where in the config 😇). Although these things are easy to add later if we find a good time slot to merge the first batch.

@Schmluk Schmluk mentioned this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants