ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

YAML File Not Loading files

asked 2016-08-02 17:44:09 -0600

Pototo gravatar image

updated 2016-08-02 17:49:31 -0600


I created my a YAML file. When I change the parameters in my YAML, then don't change in my code. I created the yaml inside my launch folder:


min_user_distance: 0.9 ...


  class myClass
     ros::NodeHandle nh_;

          myClass(int32_t user_id)
          : it_(nh_)
              std::cout << "\n---------------------------\n";
              std::cout << "Object Parameters (CAMERA):\n---------------------------\n";
              //parameters from a YAML File
              nh_.param("min_user_distance", min_user_distance_, 0.9);
              std::cout << "min_user_distance = " << min_user_distance_ << "\n";
              nh_.param("max_user_distance", max_user_distance_, 1.8);
              std::cout << "max_user_distance = " << max_user_distance_ << "\n";

And this is how I load the yaml in my my_launch_file. launch

  <node name="my_node" pkg="my_package" type="my_node" output="screen">
      <rosparam file="$(find my_packge)/launch/yaml_file.yaml"/>

When I change the value in the yaml file, the computer still prints 0.9 for the min_user_distance_ (which is the default value). Why does it always pick the default value?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-02 20:27:51 -0600

Mark Rose gravatar image

According to the documentation of the <rosparam> tag ( ):

The <rosparam> tag can be put inside of a <node> tag, in which case the parameter is treated like a private name.

So your code to get the parameters should use private names:

nh_.param("~min_user_distance", min_user_distance_, 0.9);
std::cout << "min_user_distance = " << min_user_distance_ << "\n";
nh_.param("~max_user_distance", max_user_distance_, 1.8);
std::cout << "max_user_distance = " << max_user_distance_ << "\n";

Alternatively, to create global parameters put the <rosparam> tag outside the <node> tag.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-08-02 17:44:09 -0600

Seen: 364 times

Last updated: Aug 02 '16