Add urdf file extension case to mj_parse.
fixes #3004 PiperOrigin-RevId: 855249634 Change-Id: I6c21d0ada4fe482059f64e96d413796f5c1c66ce
This commit is contained in:
committed by
Copybara-Service
parent
013268c283
commit
7e45bbb51c
@@ -479,6 +479,14 @@ class SpecsTest(absltest.TestCase):
|
||||
# Check that the state is the same.
|
||||
np.testing.assert_array_equal(state1, state2)
|
||||
|
||||
def test_parses_urdf(self):
|
||||
file_path = epath.resource_path("mujoco") / "testdata" / "model.urdf"
|
||||
filename = file_path.as_posix()
|
||||
|
||||
# Load from file.
|
||||
spec1 = mujoco.MjSpec.from_file(filename)
|
||||
self.assertIsNotNone(spec1)
|
||||
|
||||
def test_make_mesh(self):
|
||||
spec = mujoco.MjSpec()
|
||||
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<robot name="tool">
|
||||
<link name="tool"/>
|
||||
</robot>
|
||||
@@ -58,6 +58,7 @@ mujoco = [
|
||||
"testdata/*.msh",
|
||||
"testdata/*.usda",
|
||||
"testdata/*.zip",
|
||||
"testdata/*.urdf",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
@@ -72,7 +72,9 @@ mjSpec* mj_parse(const char* filename, const char* content_type,
|
||||
|
||||
// early exit for existing XML workflow
|
||||
auto filepath = mujoco::user::FilePath(filename);
|
||||
if (filepath.Ext() == ".xml" || (content_type && std::strcmp(content_type, "text/xml") == 0)) {
|
||||
if (filepath.Ext() == ".xml" ||
|
||||
filepath.Ext() == ".urdf" ||
|
||||
(content_type && std::strcmp(content_type, "text/xml") == 0)) {
|
||||
return mj_parseXML(filename, vfs, error, error_sz);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user