Skip to content

Commit

Permalink
fix: avoid conflict with get_parameter (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
domire8 committed Oct 24, 2023
1 parent 9fddd2d commit 4fcd1e5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Release Versions:

## Upcoming changes (in development)

- Avoid conflict with get_parameter (#42)
- Revise ComponentInterface by moving implementations to source file (#39)
- Update component classes to inherit from new ComponentInterface (#38)
- Refactor ComponentInterface to use node interfaces (#33)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Component : public rclcpp::Node, public ComponentInterface {
virtual ~Component() = default;

protected:
/**
* @copydoc ComponentInterface::get_parameter
*/
[[nodiscard]] std::shared_ptr<state_representation::ParameterInterface> get_parameter(const std::string& name) const;

/**
* @brief Start the execution thread.
*/
Expand Down Expand Up @@ -76,6 +81,7 @@ class Component : public rclcpp::Node, public ComponentInterface {
void on_execute();

// TODO hide ROS methods
using ComponentInterface::get_parameter;
using ComponentInterface::create_output;
using ComponentInterface::inputs_;
using ComponentInterface::outputs_;
Expand All @@ -84,6 +90,7 @@ class Component : public rclcpp::Node, public ComponentInterface {
using ComponentInterface::publish_predicates;
using ComponentInterface::publish_outputs;
using ComponentInterface::evaluate_periodic_callbacks;
using rclcpp::Node::get_parameter;

std::thread execute_thread_; ///< The execution thread of the component
bool started_; ///< Flag that indicates if execution has started or not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon
virtual ~LifecycleComponent() = default;

protected:
/**
* @copydoc ComponentInterface::get_parameter
*/
[[nodiscard]] std::shared_ptr<state_representation::ParameterInterface> get_parameter(const std::string& name) const;

/**
* @brief Steps to execute when configuring the component.
* @details This method can be overridden by derived Component classes.
Expand Down Expand Up @@ -256,6 +261,7 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon
bool clear_signals();

// TODO hide ROS methods
using ComponentInterface::get_parameter;
using ComponentInterface::create_output;
using ComponentInterface::inputs_;
using ComponentInterface::outputs_;
Expand All @@ -264,6 +270,7 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon
using ComponentInterface::publish_predicates;
using ComponentInterface::publish_outputs;
using ComponentInterface::evaluate_periodic_callbacks;
using rclcpp_lifecycle::LifecycleNode::get_parameter;
};

template<typename DataT>
Expand Down
5 changes: 5 additions & 0 deletions source/modulo_components/src/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ void Component::on_execute() {
bool Component::on_execute_callback() {
return true;
}

std::shared_ptr<state_representation::ParameterInterface>
Component::get_parameter(const std::string& name) const {
return ComponentInterface::get_parameter(name);
}
}// namespace modulo_components
5 changes: 5 additions & 0 deletions source/modulo_components/src/LifecycleComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ LifecycleComponent::LifecycleComponent(const rclcpp::NodeOptions& node_options,
});
}

std::shared_ptr<state_representation::ParameterInterface>
LifecycleComponent::get_parameter(const std::string& name) const {
return ComponentInterface::get_parameter(name);
}

void LifecycleComponent::step() {
try {
if (this->get_predicate("is_active")) {
Expand Down

0 comments on commit 4fcd1e5

Please sign in to comment.