From ba90650f72aec7c31e2c3fac05140498b4099bbc Mon Sep 17 00:00:00 2001 From: zevbo Date: Thu, 31 Aug 2023 10:46:01 -0400 Subject: [PATCH 1/2] fixing check urdf --- urdf_compose/__init__.py | 10 +++++++++- urdf_compose/urdf_obj.py | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/urdf_compose/__init__.py b/urdf_compose/__init__.py index 0c9426a..28cbec0 100644 --- a/urdf_compose/__init__.py +++ b/urdf_compose/__init__.py @@ -14,7 +14,13 @@ URDFConn, ) from urdf_compose.urdf_compose_error import URDFComposeError -from urdf_compose.urdf_obj import CheckURDFFailure, ExplicitURDFObj, URDFObj +from urdf_compose.urdf_obj import ( + CheckURDFFailure, + ExplicitURDFObj, + URDFObj, + globally_disable_check_urdf, + globally_enable_check_urdf, +) __version__ = "0.2.1" @@ -34,4 +40,6 @@ "CheckURDFFailure", "write_and_check_urdf", "raise_if_compose_error", + "globally_disable_check_urdf", + "globally_enable_check_urdf", ] diff --git a/urdf_compose/urdf_obj.py b/urdf_compose/urdf_obj.py index 8715c06..4a988ad 100644 --- a/urdf_compose/urdf_obj.py +++ b/urdf_compose/urdf_obj.py @@ -47,7 +47,31 @@ class CheckURDFFailure(Exception): pass +_global_check_urdf_enabled = True + + +def globally_disable_check_urdf() -> None: + """ + If you can't install check_urdf, you can globally disable it here + If you do, the "check_urdf" will always just return None + """ + global _global_check_urdf_enabled + _global_check_urdf_enabled = False + + +def globally_enable_check_urdf() -> None: + """ + check_urdf will default to be enabled, but if you disable it, + you can re-enable it here + """ + global _global_check_urdf_enabled + _global_check_urdf_enabled = True + + def check_urdf(urdf_path: Path) -> CheckURDFFailure | None: + if not _global_check_urdf_enabled: + return None + with subprocess.Popen( [f'check_urdf "{urdf_path}" > /dev/null'], stdout=subprocess.PIPE, From 8467eb4e48f523b6da6a5a867e51e984e7af4ca9 Mon Sep 17 00:00:00 2001 From: zevbo Date: Thu, 31 Aug 2023 10:48:53 -0400 Subject: [PATCH 2/2] updating readme more --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37c753b..926fa93 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,15 @@ This package provides another solution by allowing one to dynamically compose ur ## Installation -Install with: -```pip install urdf-compose``` +Install urdf-compose: ```pip install urdf-compose``` + +It is also recommended to install check-urdf. + +For Ubuntu: `sudo apt-get install liburdfdom-tools` +For Mac: `brew install urdfdom` +Other Operating Systems: https://command-not-found.com/check_urdf + +If you can't install `check-urdf`, you must disable it in urdf compoe using `globally_disable_check_urdf` ## Usage