Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added execute argument to rosparam, to load the output of a command as yaml #1170

Closed
wants to merge 1 commit into from

Conversation

marbosjo
Copy link

@marbosjo marbosjo commented Sep 22, 2017

This PR add a "execute" argument to tag of roslaunch files. This allows to load parameters from the output of a command, similar to the "command" attribute of tag.

The command to be executed is specified by an argument called "execute", as argument "command" is already used to specify if parameters must be loaded/dumped/deleted.

"execute" argument will be ignored if "file" argument is set.

The output of the executed command must be a valid yaml file, otherwise it is not loaded.

This PR is similar to #1045, but does not need to set an additional root name for the parameters loaded.

Check the attached example files:

$ cat $HOME/rosparam_example.yaml
parameter_1: hello
parameter_2: 2000
root_parameter:
  child_parameter_1: 1000
  child_parameter_2: child_2

$ cat $HOME/test_rosparam.launch 
<launch>
  <rosparam command="load" execute="cat $(env HOME)/rosparam_example.yaml" />
</launch>

$ roslaunch ./test_rosparam.launch 
... logging to /home/robotnik/.ros/log/7d6e0f1e-9fcc-11e7-b4fb-e4a7a00a8c8c/roslaunch-thorondor-17632.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://thorondor:43653/

SUMMARY
========

PARAMETERS
 * /parameter_1: hello
 * /parameter_2: 2000
 * /root_parameter/child_parameter_1: 1000
 * /root_parameter/child_parameter_2: child_2
 * /rosdistro: lunar
 * /rosversion: 1.13.2

$ rosparam dump 
parameter_1: hello
parameter_2: 2000
root_parameter: {child_parameter_1: 1000, child_parameter_2: child_2}
rosdistro: 'lunar'

@mikepurvis
Copy link
Member

mikepurvis commented Sep 22, 2017

This is already possible as of #1045, but with a slightly different syntax:

<launch>
  <param name="my_namespace" type="yaml" command="cat /path/to/my/params.yaml" />
</launch>

Wait, I didn't see that you were already aware of that PR. I'm not sure I support adding such similar functionality in a different way. Hmm.

@marbosjo
Copy link
Author

marbosjo commented Sep 22, 2017

I think it is complementary, it is rosparam vs param tag.

Moreover, as I mentioned in the PR, with this there is no need to specify a namespace for the loaded params, so it is cleaner to load them inside a node namespace.

@dirk-thomas
Copy link
Member

Please resolve conflicts and retarget the latest default branch (currently melodic-devel) to be considered for review and merge.

@marbosjo
Copy link
Author

I'm closing this PR because #1354 solves our use case.

@marbosjo marbosjo closed this Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants