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

use NodeParameterInterface instead of /parameter_event to update "use… #2378

Draft
wants to merge 1 commit into
base: rolling
Choose a base branch
from

Conversation

fujitatomoya
Copy link
Collaborator

…_sim_time"

address #2370

// TODO(tfoote) use parameters interface not subscribe to events via topic ticketed #609
parameter_subscription_ = rclcpp::AsyncParametersClient::on_parameter_event(
node_topics_,
[this](std::shared_ptr<const rcl_interfaces::msg::ParameterEvent> event) {
this->on_parameter_event(event);
});
post_set_parameters_callback_ = node_parameters_->add_post_set_parameters_callback(
std::bind(&TimeSource::NodeState::post_set_parameters, this, std::placeholders::_1));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using NodeParameterInterface instead of /parameter_event provides significant efficiency especially ROS 2 system has many nodes in the network. with this fix, we do not need to receive all the events and filter the node and use_sim_time parameter from /parameter_event topic.

ParameterMutationRecursionGuard guard(parameter_modification_enabled_);
// ParameterMutationRecursionGuard guard(parameter_modification_enabled_);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this recursion guard is block this PR work.

// Internal RAII-style guard for mutation recursion
class ParameterMutationRecursionGuard
{
public:
explicit ParameterMutationRecursionGuard(bool & allow_mod)
: allow_modification_(allow_mod)
{
if (!allow_modification_) {
throw rclcpp::exceptions::ParameterModifiedInCallbackException(
"cannot set or declare a parameter, or change the callback from within set callback");
}
allow_modification_ = false;
}
~ParameterMutationRecursionGuard()
{
allow_modification_ = true;
}
private:
bool & allow_modification_;
};

i guess this is not only for this PR's blocker, but also when we create either publisher or subscription with overriding the QoS parameters enabled via parameter callback. i guess it is something user would do when the specific parameter is enabled, and then create the subscription with QoS override. this will be generating rclcpp::exceptions::ParameterModifiedInCallbackException because it eventually call rclcpp::detail::declare_qos_parameters.

i will submit the issue to open this discussion.

@fujitatomoya
Copy link
Collaborator Author

CC: @Barry-Xu-2018 @iuhilnehc-ynos

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.

1 participant