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

xacro processing in ROS 2 YAML launch files (or XML)?

asked 2023-03-27 17:02:01 -0500

danzimmerman gravatar image

I'm trying to use YAML launch files for a Gazebo simulation project I'm working on, but it doesn't seem like there's a lot of documentation beyond the basics here.

I need to process a robot description xacro and pass that as a param to robot_state_publisher.

Does the YAML frontend support this?

Does someone know of an example in an existing package?

I should be able to RUN the xacro processing with an executable but it's not clear how I'd store and access the variable. (I could probably put it into an env var and then read the env var, but that seems like a roundabout way to

https://design.ros2.org/articles/rosl...

Here I'm linking to XML docs because there's not much on YAML that I can find, but it seems from other recent investigations like YAML and XML are almost exactly the same.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2023-03-27 20:22:12 -0500

danzimmerman gravatar image

I found the answer here https://github.com/ros2/launch/issues...

There is a $(command ...) substitution that can be processed into a value, like:

- let:
    name: "robot_description_content"
    value: "$(command '$(find-exec xacro) $(var robot_xacro) name:=ur ur_type:=ur5e')"

Ultimately the same as launch.substitutions.Command() in a Python launch file.

edit flag offensive delete link more
1

answered 2023-06-13 18:56:40 -0500

chives_onion gravatar image

updated 2023-06-14 08:51:25 -0500

In an xml launch file I was able to process my xacro via

<node pkg="robot_state_publisher" exec="robot_state_publisher"
        <param name='robot_description' type="str" value="$(command 'xacro $(find-pkg-share myrobot_description)/urdf/robot.urdf.xacro')"/>
</node>

Note that I added the following line to the data_files member in setup.py

(os.path.join('share', package_name, 'urdf'), glob(os.path.join('urdf', '*[urdf][xacro]*')))

This was a slightly different approach than stated in the urdf tutorial and allowed my description files to be copied to the shared directory within a urdf folder.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-03-27 17:02:01 -0500

Seen: 350 times

Last updated: Jun 14 '23