Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check urdf use correctly #7

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion urdf_compose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.0"

Expand All @@ -34,4 +40,6 @@
"CheckURDFFailure",
"write_and_check_urdf",
"raise_if_compose_error",
"globally_disable_check_urdf",
"globally_enable_check_urdf",
]
24 changes: 24 additions & 0 deletions urdf_compose/urdf_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading