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

load parameters from yaml file API

asked 2012-04-13 22:08:38 -0500

K Chen gravatar image

updated 2012-04-14 06:36:55 -0500

joq gravatar image

Is there a way to load .yaml file in C++ and override the parameters in some given namespace? I know this can be done in launch files using <rosparam load...>, but can I do it in my code? Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-04-14 06:51:15 -0500

joq gravatar image

updated 2012-04-14 18:35:51 -0500

You can use yaml-cpp to read the dump file yourself, but I don't recommend it. For most ROS applications, <rosparam load ...> will be cleaner and more flexible.

Why do you prefer handling it yourself?

ANSWER: to provide parameter persistence.

UPDATE: I think the usual solution is to run "rosparam dump" before shutting down the parameter server.

There should be an automatic way to do that, but I don't know how. Maybe someone else can suggest a good technique. I guess you could run system("rosparam dump ...") yourself before exiting.

edit flag offensive delete link more

Comments

Because I want to keep the parameters in ParamServer and .yaml files synchronized, e.g. changing the .yaml file could affect the params, and when the application exits, the .yaml file could be updated to store the newly updated params.

K Chen gravatar image K Chen  ( 2012-04-14 17:16:22 -0500 )edit

Does ROS have this kind of API?

K Chen gravatar image K Chen  ( 2012-04-14 17:18:52 -0500 )edit

Thanks for your reply, but I am looking for some automatic way to do that in C++ (rosparam is written in python though, and there are differences between rospy and roscpp APIs)

K Chen gravatar image K Chen  ( 2012-04-14 20:21:13 -0500 )edit

You can call system() in C++.

joq gravatar image joq  ( 2012-04-15 03:50:23 -0500 )edit

Hi joq. I know this is an old post. Have you figured it out how to load YAML instead of using rosparam load in C++? I am facing the same question now. Thanks!

HarryLi gravatar image HarryLi  ( 2023-07-05 10:48:52 -0500 )edit

Question Tools

Stats

Asked: 2012-04-13 22:08:38 -0500

Seen: 4,111 times

Last updated: Apr 14 '12