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

How can I load a yaml rosparam file for a nodelet?

asked 2017-08-15 05:29:53 -0600

themightyoarfish gravatar image

Usually, when writing a launch file and wanting to set many rosparams at once, one would place them in a YAML file which is then loaded for the node like this:

        name="$(arg node_name)"
        respawn="$(arg respawn)"
        launch-prefix="$(arg launch_prefix)" >
        <param name="camera_frame" value="$(arg node_name)" type="string" />
        <rosparam command="load" file="$(arg config_file)" />

Now, the same does not seem to work in a nodelet.

<node if="$(arg start_pylon_driver)"
    args="load pylon_camera/PylonNodelet $(arg manager_name)"
      <param name="camera_frame" value="pylon_camera" type="string" />
      <rosparam command="load" file="$(arg config_file)" />

The nodelet loads and runs, but the parameters are all default values, not the ones set in the config.yaml. How can this be accomplished?

edit retag flag offensive close merge delete


What pylon_camera is this? doesn't support nodelets.

lucasw gravatar image lucasw  ( 2017-08-15 08:42:37 -0600 )edit

What do you mean it doesn't support nodelets? I simply made the required additions to the codebase, it's basically as simple as writing a nodelet subclass which does what main.cpp does otherwise. The nodelet is working alright, it just doesn't respect the config params.

themightyoarfish gravatar image themightyoarfish  ( 2017-08-15 11:12:37 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-15 09:28:12 -0600

lucasw gravatar image

updated 2017-08-15 09:28:37 -0600

It's possible the param getting is being done wrong within the nodelet, and it is loading params from the manager namespace rather than the nodelet.

The nodelet needs to be using

getPrivateNodeHandle().getParam("camera_frame", camera_frame_)

rather than the following which is what a non-nodelet node would usually do:

ros::NodeHandle nh("~");
nh.getParam("camera_frame", camera_frame_);

Also try rosparam list to see if the parameters in the yaml files are correctly being loaded.

edit flag offensive delete link more


These two code snippets look as if they were doing the same thing. isn't "~" a private namespace?

themightyoarfish gravatar image themightyoarfish  ( 2017-08-15 11:13:55 -0600 )edit

The plugins get loaded and run inside the nodelet manager, which has a different private namespace from the node that asks the manager to launch a specific nodelet. getPrivateNodeHandle() gets you the namespace of the nodelet launcher.

lucasw gravatar image lucasw  ( 2017-08-15 11:49:45 -0600 )edit

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: 2017-08-15 05:29:53 -0600

Seen: 1,950 times

Last updated: Aug 15 '17