from resolve_robotics_uri_py import resolve_robotics_uri
absolute_path = resolve_robotics_uri(
"robot://config/controller.ini", default_package_name="ControlLib"
)
For example, install the default at share/ControlLib/config/controller.ini and
an override at share/CompanyRobotConfigurations/robots/MyRobot/config/controller.ini.
Set ACTIVE_ROBOT_NAME=MyRobot (or YARP_ROBOT_NAME as a fallback). The lookup is:
A regular file at config/controller.ini in the working directory.
The robot-specific file under any immediate package's robots/<robot> directory.
The default package file, if a default package name was supplied.
The default package can also be embedded in the URI:
Results are absolute paths to regular files. Discovery of robots directories is
cached; see the search specification for refresh and error behavior.
Custom URI overrides
uri_overrides maps URI scheme names to callbacks. Keys omit ://, e.g. "home",
and match the parsed scheme exactly before normal resolution. The callback
receives the full URI and the search options as keyword arguments and returns a pathlib.Path or raises an exception.
A callback's failure does not fall back to another handler.
from pathlib import Path
from resolve_robotics_uri_py import get_default_uri_overrides, resolve_robotics_uri
# Resolve home://Documents/notes.txt inside the current user's home directory.
def resolve_home(uri, **options):
path = Path.home() / uri.partition(":")[2].removeprefix("//")
return resolve_robotics_uri(str(path), uri_overrides={}, **options)
absolute_path = resolve_robotics_uri(
"home://Documents/notes.txt",
uri_overrides={**get_default_uri_overrides(), "home": resolve_home},
)
get_default_uri_overrides() returns a fresh mapping that callers can modify
without affecting subsequent resolutions.
This resolves home://Documents/notes.txt to Documents/notes.txt under the user's
home directory, while retaining robot://. The callback also receives
default_package_name, so custom overrides can use it for their own fallback logic.
A runnable version is in examples/custom_uri_override.py.
Omitting uri_overrides uses the default robot:// handler. An explicit mapping
replaces the defaults; uri_overrides={} disables all overrides. Existing schemes
can be replaced too, e.g. a "model" callback could resolve models from an
application-specific directory. Callbacks that call the resolver again should
remove their own scheme or use an empty mapping to avoid recursion.
Command Line usage
resolve_robotics_uri_py also install a command line tool called resolve-robotics-uri-py for use in scripts, that can be used as:
The default package name is optional; without it, the package-default lookup is skipped.
For example, on bash this can be used to easily convert the a urdf specified via package:// to an sdf (assuming you have Gazebo installed), using the backtick operator:
Some packages may not be installed in standard locations, or you may want to use a custom directory structure. In such cases, you have a few options:
Option 1: Modify the Native Search Paths
You can add the search path to one of the natively supported paths of Gazebo or ROS, such as:
GZ_SIM_RESOURCE_PATH
AMENT_PREFIX_PATH
Option 2: Specify Additional Search Paths
If you prefer not to modify the default ROS or Gazebo search paths, you can use either the --package_dirs command line option or set the RRU_ADDITIONAL_PATHS environment variable:
Use together with resolve-robotics-uri-py: extensions, drivers, servers and companion tools.
urdf-parser-pyPythie’s Index: 22This package contains a python parser for the Unified Robot Description Format (URDF), which is an XML format for representing a robot model.100.7K downloads/mo