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

Substitution arg for $(find pkg) #225

Closed
Levaru opened this issue Oct 17, 2019 · 5 comments
Closed

Substitution arg for $(find pkg) #225

Levaru opened this issue Oct 17, 2019 · 5 comments

Comments

@Levaru
Copy link

Levaru commented Oct 17, 2019

Hi, I'm currently at a roadblock with this issue. Is there a way to dynamically find directory paths for packages according to xacro args that i pass into the file via roslaunch? Maybe something like the eval command from roslaunch?

This works in a launch file:

<arg name="robot_name" default="kr60" />
<arg name="robot_path" default="$(eval find( arg('robot_name')+'_description'))" />

<!-- Load urdf description -->
<param name="robot_description" command="$(find xacro)/xacro '$(arg robot_path)/urdf/$(arg robot_name).urdf.xacro'"/>

But the same thing doesn't work in a xacro file:

<xacro:arg name="robot_name" default="kr60" />
<xacro:arg name="robot_path" default="$(eval find( arg('robot_name')+'_description'))" />

<!-- Load description modules -->
<xacro:include filename="$(arg robot_path)/urdf/$(arg robot_name).xacro" />

Is eval only available for roslaunch? Would it be possible to also include it in xacro?

@rhaschke
Copy link
Contributor

No, we don't have $(eval ...) in xacro. But you can use a property within $(find):

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/xacro" name="robot" xacro:targetNamespace="http://www.ros.org">
	<xacro:property name="robot_name" value="panda" />
	$(find ${robot_name}_moveit_config)
</robot>

@martinandrovich
Copy link

@rhaschke Is it possible to nest $(find) and $(arg) without the definition of a <xacro:property />? Something like:

...value="$(find $arg('robot_name'))" ...

@guihomework
Copy link

Hi,

is it a problem to have the intermediate property being defined through the arg ?

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/xacro" name="robot" xacro:targetNamespace="http://www.ros.org">

<xacro:arg name="robot_name" default="kr60" />
<xacro:property name="robot_name" value="$(arg robot_name)" />
<xacro:arg name="robot_path" default="$(find ${robot_name}_description)" />

<!-- Load description modules -->
<xacro:include filename="$(arg robot_path)/urdf/$(arg robot_name).xacro" />
</robot>

@martinandrovich
Copy link

@guihomework No, not a problem per se; just one extra line of code. It's more of a curiosity whether it is possible to do so without the intermediate property.

@rhaschke
Copy link
Contributor

No, nested arguments are not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants