ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My apologies - I did not give full file path. Works now.

My apologies - I did not give full file path. Works now.

OK, I still find that the parameter from yaml file does not override default value in the node: Here is my example, in demo_params.yaml (see this), I would like some_int: 42 to override the default value of 30 in my code. Here is my code snippet:

TestNode::TestNode(const rclcpp::NodeOptions& options) : Node("test", options)
{
        this->declare_parameter("some_int", 30);
       ithis->declare_parameter("a_string");
       std::vector<rclcpp::parameter> params = this->get_parameters({"some_int", "a_string"});
       for (auto i : params) {
              if (i.get_name() == "some_int")
                     RCLCPP_INFO(get_logger(), "%s", i.as_int());
       }
}

This prints 30 not 42!. What am I doint wrong here? Also, changing options.automatically_declare_parameters_from_overrides(true or false) makes no difference.

Thanks, nkumar