def resolve_ros_path(path_str: str) -> str:
"""Resolve a ROS path to an absolute path."""
if path_str.startswith("package://"):
path = pathlib.Path(path_str)
package_name = path.parts[1]
relative_path = pathlib.Path(*path.parts[2:])
package_path = resolve_ros1_package(package_name) or resolve_ros2_package(package_name)
if package_path is None:
raise ValueError(
f"Could not resolve {path}."
f"Replace with relative / absolute path, source the correct ROS environment, or install {package_name}."
)
return str(package_path / relative_path)
elif path_str.startswith("file://"):
return path_str[len("file://") :]
else:
return path_str # This should be from the relative path of the urdf file otherwise it's going to be read from the current working dir
Just a heads up that relative ros path is not well implemented.
Just a heads up that relative ros path is not well implemented.