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

ROS2 xacro parsing: ${robot_ip} vs $(arg robot_ip)

asked 2021-07-22 17:02:51 -0600

AndyZe gravatar image

updated 2021-07-22 17:17:12 -0600

Recently, I found this does not parse: $(arg robot_ip)

Whereas this does parse: ${robot_ip}

Do they have different purposes? And to make things stranger, both varieties seemed to work on my coworker's computer.

Here's the full block of code, if it would be helpful:

  <xacro:macro name="load_arm" params="

      <!-- ros2 control include -->
      <xacro:include filename="$(find my_robot_description)/arms/gen3/${dof}dof/urdf/my_robot.ros2_control.xacro" />
        name="MyRobotMultiInterfaceHardware" prefix="${prefix}"
        robot_ip="${robot_ip}" />
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-22 19:59:51 -0600

shonigmann gravatar image

My understanding is that you would use the arg rospack command when attempting to parse a commandline input argument (e.g. xacro myfile.xacro myarg:=true).

You can define a default value in your file with<xacro:arg name="myarg" default="false"/>, and have them behave similarly to properties, except for the syntax of how you access the value. Rospack commands use parentheses ($())

In the file you attached, robot_ip is a param input to your macro, not an argument. Parameters are evaluated as macro-local properties, and properties and expressions are all evaluated within braces (${}).

As to why parsing $(arg robot_ip) works on your coworkers computer and not yours... I'm not entirely sure, but my hunch would be that your coworker's launch script is slightly different and they define the arg somewhere.

edit flag offensive delete link more

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: 2021-07-22 17:02:51 -0600

Seen: 59 times

Last updated: Jul 22 '21