Skip to content

Make it easier to pass custom xacro args#210

Open
nickswalker wants to merge 3 commits intorobot-descriptions:mainfrom
nickswalker:enhancement/xacro-args-api
Open

Make it easier to pass custom xacro args#210
nickswalker wants to merge 3 commits intorobot-descriptions:mainfrom
nickswalker:enhancement/xacro-args-api

Conversation

@nickswalker
Copy link
Contributor

Expose xacro_args on the get_urdf_path interface. Xacro args define reasonable (and uncountable numbers of) variations of a robot, so it makes sense to allow library users to pass their preferred args in when requesting a URDF. The user can do this currently, but must define their own module or one-off namespace.

# What it takes to pass custom xacro args without this PR
from types import SimpleNamespace

temp_module = SimpleNamespace(
    __name__="robot_descriptions.fr3_without_hand_description",
    REPOSITORY_PATH=fr3_description.REPOSITORY_PATH,
    PACKAGE_PATH=fr3_description.PACKAGE_PATH,
    XACRO_PATH=fr3_description.XACRO_PATH,
    XACRO_ARGS={"hand": "false"},
)

urdf_path = get_urdf_path(temp_module)

These uses will be somewhat non-standard definitionally, so it feels okay to not expose xacro args in the higher level loader interface.

Ultimately, I'm interested in being able to easily compose arms and grippers, for which this feature is helpful. I've included a new example script illustrating this, since it might be a common "advanced" use case. Please feel free to remove it

Copy link
Member

@stephane-caron stephane-caron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @nickswalker 👍 I fully agree with the use case of passing xacro arguments when loading a Xacro description, this looks to me like the logical next step after adding the ability to load Xacro descriptions. Your changes to the _xacro submodule look good to me.

One thing is that currently one needs to import the internal robot_descriptions._xacro submodule, as you do in the example. I'd suggest we expose xacro_args as a keyword argument to load_robot_description directly, so that users don't need to reach into the internal submodule to get the feature. Something like:

robot_description = load_robot_description(
    "fr3_description",
    xacro_args={"hand": "false"},
)

What do you think?

Finally, the arm+gripper attachment example is interesting but it looks like it's about post-hoc URDF composition rather than directly related to xacro arguments. If so, can we split it into its own PR? (I'm open to merging it as well, it's just that if we can keep things separate it's easier to discuss them on their own.)

Xacro args are often used to define
a range or reasonable customization of the
model (e.g. including/excluding a gripper
on an arm). There might be dozens of
possible variants of a particular Xacro-based
description based on these args, so it
makes sense to allow the caller to
pass their desired args.
Provides public API for loader users to pass
in xacro args
Cover this new interface with loader-specific tests
@nickswalker nickswalker force-pushed the enhancement/xacro-args-api branch from 0d1eae5 to ae067c4 Compare March 19, 2026 15:39
@nickswalker
Copy link
Contributor Author

That makes sense! I added xaco_args to the URDF-based loaders for now. There'll need to be extra plumbing the first time someone wants to add a xacro-based MJCF...

Will send separate PRs for the other items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants