rerun-io / rerun-loader-python-example-urdf

Example URDF file external data loader plugin for Rerun
Apache License 2.0
22 stars 5 forks source link

`resolve_ros_path` is relative to the working directory instead of being relative to the `urdf` file #13

Open haixuanTao opened 3 weeks ago

haixuanTao commented 3 weeks ago
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.