forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workspace: Add ros_xacro (RobotLocomotion#13022)
We plan to use this to manage robot URDFs, especially when the upstream vendor of the URDFs already stores them in xacro'd form.
- Loading branch information
1 parent
9c69017
commit 5a151dd
Showing
7 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- python -*- | ||
|
||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
load("@drake//tools/skylark:drake_py.bzl", "drake_py_unittest") | ||
|
||
drake_py_unittest( | ||
name = "xacro_smoke_test", | ||
data = [ | ||
":test/sample.xacro", | ||
":test/sample.xml.expected", | ||
"@ros_xacro//:xacro", | ||
], | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- python -*- | ||
|
||
load("@drake//tools/skylark:py.bzl", "py_binary") | ||
load("@drake//tools/workspace:generate_file.bzl", "generate_file") | ||
|
||
licenses(["notice"]) # BSD-3-Clause | ||
|
||
generate_file( | ||
name = "src/ros_xacro_main.py", | ||
# This is the same as scripts/xacro from upstream, except that we lose the | ||
# unused shebang line and we use a filename that is not subject to import | ||
# path conflicts. | ||
content = "import xacro; xacro.main()", | ||
) | ||
|
||
py_binary( | ||
name = "xacro", | ||
main = "src/ros_xacro_main.py", | ||
srcs = ["src/ros_xacro_main.py"] + glob([ | ||
"src/xacro/**", | ||
], allow_empty = False), | ||
imports = ["src"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- python -*- | ||
|
||
load("@drake//tools/workspace:github.bzl", "github_archive") | ||
|
||
def ros_xacro_repository( | ||
name, | ||
mirrors = None): | ||
github_archive( | ||
name = name, | ||
repository = "ros/xacro", | ||
# N.B. Even though 1.13.x series is not the highst-numbered release, we | ||
# are using it here because it aligns with the ROS Melodic version | ||
# released for Ubuntu 18.04. | ||
commit = "1.13.5", | ||
sha256 = "145da225ab360e4d8cb9e2a190ff7427550e65c834919f58989284bc83d8f188", # noqa | ||
build_file = "@drake//tools/workspace/ros_xacro:package.BUILD.bazel", | ||
mirrors = mirrors, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" ?> | ||
<root xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
<xacro:property name="diameter" value="2.0"/> | ||
<sphere radius="${diameter/2}"/> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" ?> | ||
<!-- =================================================================================== --> | ||
<!-- | This document was autogenerated by xacro from tools/workspace/ros_xacro/test/sample.xacro | --> | ||
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | --> | ||
<!-- =================================================================================== --> | ||
<root> | ||
<sphere radius="1.0"/> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import subprocess | ||
import unittest | ||
|
||
|
||
class XacroSmokeTest(unittest.TestCase): | ||
|
||
def test_simple_file(self): | ||
"""Check that we can run xacro on a simple file and get the expected | ||
post-processed result. | ||
""" | ||
self.maxDiff = None | ||
proc = subprocess.run([ | ||
"external/ros_xacro/xacro", | ||
"tools/workspace/ros_xacro/test/sample.xacro", | ||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
self.assertEqual(proc.returncode, 0, proc.stderr.decode("utf-8")) | ||
actual = proc.stdout.decode("utf-8") | ||
with open("tools/workspace/ros_xacro/test/sample.xml.expected") as f: | ||
expected = f.read() | ||
# We use an atypical (expected, actual) order here so that the diff | ||
# shown during failure has the correct sense of added vs removed lines. | ||
self.assertMultiLineEqual(expected.strip(), actual.strip()) |