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

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

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

AndyZe gravatar image

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

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="
    parent
    dof
    vision
    prefix
    *origin
    robot_ip
    use_fake_hardware:=false
    fake_sensor_commands:=false">

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

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Question Tools

1 follower

Stats

Asked: 2021-07-22 17:02:51 -0500

Seen: 165 times

Last updated: Jul 22 '21