Setting parameter from YAML files
Hello,
I am trying to understand setting params via .yaml file. I tried running this but I get:
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to parse parameters from file 'demo_params.yaml': Error opening YAML file, at /tmp/binarydeb/ros-dashing-rcl-yaml-param-parser-0.7.8/src/parser.c:1387
Where should demo_params.yaml be placed? The content of this file is same as in example. ROS: dashing
Thanks, nkumar
Asked by fiji3119 on 2020-03-31 21:33:15 UTC
Answers
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::vectorrclcpp::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
Asked by fiji3119 on 2020-04-01 08:44:09 UTC
Comments