Skip to content

Structure of generated interface #7

Description

@tylerjw

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();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions