Skip to content

Add xacro support #420

Description

@frneer

It would be good to have a xacro rule that allows generating URDF/SDF artifacts.

Given the following xacro

<!-- urdf/robot.urdf.xacro -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <!-- Should be able to compose with local `.xacros` -->
  <xacro:include filename="$(find my_robot)/urdf/macros.xacro"/>
  <!-- Should be able to bring `.xacros` installed in the system (via `realsense2_description` for this example)-->
  <xacro:include filename="$(find realsense2_description)/urdf/_d435i.urdf.xacro"/>
   <!-- Should be able to retrieve xacro args-->
   <xacro:arg name="sim" default="true" />
</robot>

Example API

# BUILD.bazel
load("@bazel_ros2_rules//lib:ament_index.bzl", "ament_index_share_files")
load("@bazel_ros2_rules//lib:xacro.bzl", "ros_xacro")

# Registers custom ROS package "my_robot" with its share files.
ament_index_share_files(
    name = "my_robot_index",
    package_name = "my_robot",
    srcs = glob(["urdf/**"]),
)

ros_xacro(
    name = "robot.urdf",
    src = "urdf/robot.urdf.xacro",
    ros_packages = [
        ":my_robot_index",                      # custom package via ament_index_share_files
        "@ros2//:realsense2_description_share", # system package share files
    ],
    xacro_args = ["sim:=true"],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions