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

Structure of generated interface #7

Open
tylerjw opened this issue Jul 7, 2022 · 1 comment
Open

Structure of generated interface #7

tylerjw opened this issue Jul 7, 2022 · 1 comment

Comments

@tylerjw
Copy link
Contributor

tylerjw commented Jul 7, 2022

description yaml file:

topic: <>
input_rate: <>
updater:
  topic: <>
// namespace is interface library name
namespace foo_config {

struct Params {
  string topic;
  double input_rate;
  struct Updater {
    string topic;
  } updater;

  // for detecting if the parameter struct has been updated
  rclcpp::Time __stamp;
};

class ParamListener {
 public:
  ParamListener(rclcpp::ParameterInterface);
  ParamListener(rclcpp::Node::SharedPtr node) 
    : ParameterListener(node->get_parameters_interface()) {}
  ParamListener(rclcpp_lifecycle::LifecycleNode::SharedPtr node) 
    : ParameterListener(node->get_parameters_interface()) {}
  Params get() const;
  bool is_invalid(Params const& other) const;

 private:
  std::mutex mutex_;
  Params params_;
};

} // namespace foo_config

Use Example

// initalization
auto const node = std::make_shared<rclcpp::Node>("foo");
auto const param_listener = foo_config::ParameterListener(node);
auto params = param_listener.get();

...
// in update loop
if (param_listener.is_invalid(params)) {
  params = param_listener.get();
}
@pac48
Copy link
Owner

pac48 commented Jul 19, 2022

See this commit for change: 028f5d8

@pac48 pac48 closed this as completed Jul 19, 2022
@pac48 pac48 reopened this Jul 20, 2022
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

No branches or pull requests

2 participants