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

Substitutions in XML are not expanded intuitively when used for the purpose of executing programs. #710

Open
rodericktaylor opened this issue Jun 7, 2023 · 1 comment · May be fixed by #711
Assignees

Comments

@rodericktaylor
Copy link

rodericktaylor commented Jun 7, 2023

Bug report

Required Info:

  • Operating System:
    Ubuntu 22.04
  • Installation type:
    Source build (humble)
  • Version or commit hash:
    ros2/launch aed025e
  • DDS implementation:
    default, eprosima fastdds
  • Client library (if applicable):
    N/A

Steps to reproduce issue

add_model_launch.xml

<launch>
  <arg name="initial_pose" default="-x 0.0 -y 0.0 -z 0.2"/>

  <arg name="model_name" default="robot"/>

  <arg name="model_type" default="robot"/>

  <node pkg="ros_gz_sim" exec="create" name="$(var model_name)_spawner"
    args="-name $(var model_name) -param robot_description $(var initial_pose)">
    <param name="robot_description"
      value="$(command 'xacro $(find-pkg-share robot_gazebo)/models/$(var model_type)/model.urdf.xacro')"/>
  </node>

</launch>

ros2 launch my_package add_model_launch.xml

Expected behavior

When the arguments to create are processed, $(var initial_pose) is expanded to [...'-x','0.0','-y','0.0','-z','0.2'] (i.e. multiple list items) for command execution. This is so that the create node executable recognises the command arguments.

Additionally, when executed with the -d flag, launch should log the command as an array of strings, as this is what is supplied to the operating system call. Example provided below.

process details: cmd=['/path/to/ros_gz_sim/lib/ros_gz_sim/create','-name','robot','-param','robot_description','-x','0.0','-y','0.0','-z','0.2','--ros-args','-r','__node:=robot_spawner','--params-file','/tmp/launch_params_958ns6s1'], cwd='None', custom_env?=True

Actual behavior

When the arguments to create are expanded $(var initial_pose) is expanded to [...'-x 0.0 -y 0.0 -z 0.2'] (.i.e a single list item) for command execution. The create command does not recognise these as a single argument string.

I had to hack the code to force it to log the command being executed. There is an implementation there, but I could not find how to turn it on. This implementation logs the command executed as a joined string, which hid this issue.

process details: cmd='/path/to/ros_gz_sim/lib/ros_gz_sim/create -name robot -param robot_description -x 0.0 -y 0.0 -z 0.2 --ros-args -r __node:=robot_spawner --params-file /tmp/launch_params_958ns6s1', cwd='None', custom_env?=True

Additional information

A work around is to ensure substitutions expand to strings without spaces in them.

i.e.

  <arg name="initial_pose_x" default="0.0"/>
  <arg name="initial_pose_y" default="0.0"/>
  <arg name="initial_pose_z" default="0.2"/>

I suspect this may also be an issue for yaml, but did not test.

@rodericktaylor rodericktaylor changed the title Substitutions in XML are not Substitutions in XML are not expanded intuitively when used for the purpose of executing programs. Jun 7, 2023
@wjwwood
Copy link
Member

wjwwood commented Jun 15, 2023

I just ran into this myself, this is my proposed fix, but right now it causes test failures, so I'll need to look into it more:

#711

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

Successfully merging a pull request may close this issue.

2 participants