Skip to content

Node parameters callback called five times for changes to use_sim_time #1566

@jacobperron

Description

@jacobperron

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • from source
  • Version or commit hash:
  • DDS implementation:
    • N/A
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Build the following node:

#include <iostream>
#include <memory>

#include "rclcpp/rclcpp.hpp"

int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);
  auto node = std::make_shared<rclcpp::Node>("foo_node");

  auto param_change_callback =
    [](std::vector<rclcpp::Parameter> parameters)
    {
      std::cerr << "Parameter callback" << std::endl;
      auto result = rcl_interfaces::msg::SetParametersResult();
      result.successful = true;
      return result;
    };
  auto param_callback_handle = node->add_on_set_parameters_callback(param_change_callback);

  rclcpp::spin(node);

  rclcpp::shutdown();
  return 0;
}

Run it and then set the use_sim_time parameter on it:

ros2 param set /foo_node use_sim_time true

Expected behavior

The parameter is set successfully and the registered callback is called once.

Actual behavior

The parameter is set successfully and the registered callback is called five times.

Additional information

I've experimented with a user-defined parameter, and do not experience this issue (i.e. the parameter callback is called exactly once).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions