ros2 / ros2/rclcpp

AsyncParametersClient and get_parameter not working as expected

Open
#2,748 4 comments 0 reactions 1 assignee View on GitHub

@alsora is already working on this.

Since Feb 27, 2025.

Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

AsyncParametersClient and get_parameter Synchronization Issues

Description

There are synchronization issues between AsyncParametersClient::load_parameters() and Node::get_parameter() that make it difficult to reliably load and read parameters.

Problem

When loading parameters from a YAML file:

// Load parameters
parameters_client_->load_parameters(yaml_filepath_);

// Try to get updated values
get_parameter("number_particles", num_particles);  // Still returns old value

Attempted solutions that don't work:

  1. Using futures:
auto future = parameters_client_->load_parameters(yaml_filepath_);
future.wait();  // Hangs indefinitely
  1. Using delays:
parameters_client_->load_parameters(yaml_filepath_);
std::this_thread::sleep_for(std::chrono::seconds(5));  // Even long delays don't help
get_parameter("number_particles", num_particles);  // Still returns old value
  1. Double loading:
parameters_client_->load_parameters(yaml_filepath_);
parameters_client_->load_parameters(yaml_filepath_);  // Try to force an update

The only way to get the updated values is to wait for another parameter event to trigger, suggesting the parameter cache isn't being properly updated.

Expected Behavior

  • load_parameters() should complete and ensure parameters are updated
  • get_parameter() should return the latest values immediately after loading

Actual Behavior

  • get_parameter() returns stale values until another parameter event occurs
  • Futures from load_parameters() hang indefinitely
  • No reliable way to synchronize parameter loading and reading

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.