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

parameter passed to xacro not changing the default one

asked 2022-03-10 08:43:50 -0500

sniegs gravatar image

updated 2022-04-27 01:24:32 -0500

I'm trying to make a .xacro file for a UR5e robot, that allows choosing the gripper at launch, which means choosing different macros inside of it and I'm doing it based on the answer here. The setup is based on the ur moveit config so launching the robot goes like this:

  1. You launch robot_setup.launch
  2. which launches planning_execution.launch
  3. which then launches planning_context.launch
  4. from which the robot.xacro is read as a <param...

I want to change a parameter at robot_setup.launch and have it change a parameter in the .xacro.

Snippet of the xacro code:

<xacro:arg name="gripper_type" default="other"/>
<xacro:property name="gripper_type" value="$(arg gripper_type)" />

<!-- instantiating arm and gripper -->
<xacro:if value="${gripper_type == 'robotiq'}">
    <xacro:robotiq_arg2f_140 prefix="${arm_prefix}"/>
</xacro:if>

<xacro:if value="${gripper_type == 'other'}">
    <xacro:vacuum_gripper_definition prefix="${arm_prefix}" gripper_adjustment="0.00"/>
</xacro:if>

So I'm trying to pass gripper_type from the robot_setup.launch all the way through the mentioned files, to change it in the .xacro, but in the end, the default value in the .xacro stays unchanged, so what am I doing wrong?

Snippet from setup.launch:

<arg name="gripper_type" default="other" />

<include file="$(find moveit_config)/launch/planning_execution.launch">
    <arg name="gripper_type" value="$(arg gripper_type)" />
</include>

Snippet from planning_execution.launch:

  <arg name="gripper_type"/>

  <include file="$(find moveit_config)/launch/planning_context.launch" >
    <arg name="load_robot_description" value="true"/>
    <arg name="gripper_type" value="$(arg gripper_type)"/>
  </include>

Snippet from planning_context.launch:

<arg name="gripper_type"/> 

<param if="$(arg load_robot_description)" name="$(arg robot_description)" command="xacro '$(find robot_config)/urdf/.xacro' gripper_type:=$(arg gripper_type)"/>
edit retag flag offensive close merge delete

Comments

What command are you using to run setup.launch?

tryan gravatar image tryan  ( 2022-03-11 10:01:31 -0500 )edit
1

I deleted my answer: passing user args to xacro using a syntax like n:=42 is supported in melodic.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-03-12 11:11:57 -0500 )edit

@tryan I run it with roslaunch, if it's of some importance, the roscore is on a second computer and they are connected through rosmaster, perhaps I needed to restart the whole roscore for the changes to take effect?

sniegs gravatar image sniegs  ( 2022-03-13 06:35:52 -0500 )edit

It shouldn't matter where the master is running. I see that your xacro file defaults to "other," and that is also the default in setup.launch. What command are you using that you expect to get a different value for gripper_type?

tryan gravatar image tryan  ( 2022-03-13 15:49:24 -0500 )edit

@tryan gripper_type is the variable I've added in xacro. It has values "other" and "robotiq". I wasn't able to launch it without setting a default in both the setup.launch and xacro. The command for launching would be roslaunch package setup.launch gripper_type:=robotiq or other, depending on the situation

sniegs gravatar image sniegs  ( 2022-03-14 01:54:01 -0500 )edit
  1. Have you tried using the new syntax <xacro:arg ...> and <xacro:include ...>?

  2. It's not clear to me that you can redefine an xacro:arg, or pass it "into" an included file. If xacro app reads the text content of the named file and interprets it in the parent's context, then the xacro:arg defined in the parent would be used to expand the content of the included file.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-04-27 06:06:51 -0500 )edit

Ugh. I got confused between include in launch file and include in the xacro file. I will look at the issue again.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-04-27 15:02:11 -0500 )edit

Based on what you provided above, my experiments show the xacro:property being set to the expected value. Do you get the desired urdf if you directly run xacro from the command line?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-04-28 06:38:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-04-28 03:43:25 -0500

Joe28965 gravatar image

I had a very similar problem a few years ago, I asked a question here too.

Check that you don't make the same mistake as I did. It seems like you're also using robot_description as a parameter. Is that parameter overwritten somewhere else to go back to the default (gripper_type=other)?

edit flag offensive delete link more

Comments

Yes thank you! In the setup.launch, not only planning_execution.launch launches .xacro down stream, but so does bringup.launch so the issue was excatly that, that is set it to default in the other stream.

sniegs gravatar image sniegs  ( 2022-04-29 02:47:20 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-03-10 08:43:50 -0500

Seen: 155 times

Last updated: Apr 28 '22