0
$\begingroup$

Rosanswers logo

If I do this:

 <rosparam command="load" file="$(find mypkg)/config/example.yaml" />

Can I then use values set in the yaml as arguments going into a xacro file?

(I haven't experimented much here and I'll update this when I do try it tomorrow, but it seems like the documentation says only the other direction is possible: values can be set on the parameter server from within a launch file, and the local copies of those values can be used inside that same launch file and used as arguments, but there is no read access to the parameter server?)


Originally posted by lucasw on ROS Answers with karma: 8729 on 2014-01-06

Post score: 1


Original comments

Comment by ahendrix on 2014-01-06:
I'm not sure this is possible. You may get better answers if you elaborate on why you want to do this.

Comment by lucasw on 2014-01-08:
I'd like to have a centralized place (the yaml file) defining critical robot dimensions, then pass these into a xacro file defining the robot, but also allow certain nodes to get some of the same dimensions from the parameter server.

Comment by fvd on 2017-06-04:
How did you end up solving this? Did you find a satisfactory solution?

Comment by lucasw on 2017-06-13:
I saw another question similar to this http://answers.ros.org/question/263768/yaml-parameters-to-node-args/ and then starting trying out using eval in kinetic to try to access the parameter server (see the comments), but so far no luck.

Comment by lucasw on 2017-06-13:
It would be nice if there was a $(load_param /foo/x) but maybe there would be race conditions with <param ... setting in the same launch files?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Not entirely sure this is what you are looking for, but have you seen the yaml support in the Jade+ version of xacro?

Properties can be dictionaries or lists too - manually declared with python syntax, like so:

<xacro:property name="props" value="${dict(a=1, b=2, c=3)}"/>
    <xacro:property name="numbers" value="${[1,2,3,4]}"/>

or loaded from YAML files like so:

<xacro:property name="props" value="${load_yaml('props.yaml')}"/>

You can do some pretty complex things with this, especially when you combine it with the other new features xacro gained. See ubi-agni/human_hand for an example.


Originally posted by gvdhoorn with karma: 86574 on 2017-06-13

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by lucasw on 2017-06-13:
I hadn't heard about that so I'm now subscribed to the xacro wiki page. I wonder if it would be more straight-forward at this point to originate a robot_description in python instead of xacro.

Comment by gvdhoorn on 2017-06-14:
re: python: well, that's the age old debate on whether a general purpose language could do things 'easier' or 'more efficient' than a DSL. I don't know. Both have their (dis)advantages.

There have been earlier attempts at using Python for this.

$\endgroup$
0
$\begingroup$

Rosanswers logo

I think the better solution here is for any node that needs the dimensions of the robot should pull them from the URDF that's already on the parameter server, or from one of the static transforms that's published based on the URDF.


Originally posted by ahendrix with karma: 47576 on 2014-01-08

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by Martin Günther on 2014-01-08:
I agree. Just as a pointer to inexperienced users, there are URDF parsers for both Python and C++ here: https://github.com/ros/urdfdom .

Comment by lucasw on 2014-01-10:
It looks like following http://wiki.ros.org/urdf/Tutorials/Parse%20a%20urdf%20file but with initParam("/robot_description") instead of initFile() would work. Traversing the urdf data structure to find a dimension seems like a lot of work compared to using the input dimension from the source.

Comment by lucasw on 2014-01-10:
Using the tf provided by robot_state_publisher avoids a lot of parsing work, and I could create artificial links in the urdf that exist only to be measured through tf. It can be an error check to define a value, create something from it, and then measure it again as opposed to using the original.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.