Skip to content

compas_robots.resources ¤

Model descriptions rarely embed geometry directly; instead, they reference it through filenames or URLs pointing to externally hosted resources. This package provides loader classes that automate fetching and processing those resources.

Classes¤

AbstractMeshLoader ¤

Basic contract/interface for all mesh loaders.

Functions¤

can_load_mesh ¤
can_load_mesh(url: str) -> bool

Determine whether this loader can load a given Mesh URL.

Parameters:

  • url (str) –

    Mesh URL.

Returns:

  • bool

    True if it can handle it, otherwise False.

load_meshes ¤
load_meshes(url: str, precision: int | None = None) -> list[Mesh]

Load meshes from the given URL.

A single mesh file can contain multiple meshes depending on the format.

Parameters:

  • url (str) –

    Mesh URL

  • precision (int | None, default: None ) –

    The precision for parsing geometric data.

Returns:

  • List of meshes.

DefaultMeshLoader ¤

DefaultMeshLoader(**kwargs)

Handles basic mesh loader tasks, mostly from local files.

Attributes:

  • kwargs (optional) (dict) –

    Additional keyword arguments.

Functions¤

can_load_mesh ¤
can_load_mesh(url: str) -> bool

Determine whether this loader can load a given mesh URL.

Parameters:

  • url (str) –

    Mesh URL.

Returns:

  • bool

    True if the URL points to a local and valid file. Otherwise False.

load_meshes ¤
load_meshes(url: str, precision: int | None = None) -> list[Mesh]

Load meshes from the given URL.

A single mesh file can contain multiple meshes depending on the format.

Parameters:

  • url (str) –

    Mesh URL

  • precision (int | None, default: None ) –

    The precision for parsing geometric data.

Returns:

  • List of meshes.

GithubPackageMeshLoader ¤

GithubPackageMeshLoader(
    repository: str,
    support_package: str,
    branch: str = "main",
    relative_path: str | None = None,
)

Loads resources stored in Github.

Attributes:

  • repository (str) –

    Repository name including organization, e.g. ros-industrial/abb.

  • support_package (str) –

    Name of the support package containing URDF, Meshes and additional assets, e.g. abb_irb4400_support

  • branch (str) –

    Branch name, defaults to main.

  • relative_path (str) –

    Relative path of the support package within the repository. If the repository itself is the support package, set relative_path to '.'. Defaults to support_package

Functions¤

build_url ¤
build_url(file: str) -> str

Returns the corresponding url of the file.

Parameters:

  • file (str) –

    File name. Following convention, the file should reside inside a urdf folder.

Returns:

  • The file's url.
can_load_mesh ¤
can_load_mesh(url: str) -> bool

Determine whether this loader can load a given mesh URL.

Parameters:

  • url (str) –

    Mesh URL.

Returns:

  • bool

    True if the URL uses the package:// scheme and the package name matches the specified in the constructor, otherwise False.

load_meshes ¤
load_meshes(url: str, precision: int | None = None) -> list[Mesh]

Load meshes from the given URL.

A single mesh file can contain multiple meshes depending on the format.

Parameters:

  • url (str) –

    Mesh URL

  • precision (int | None, default: None ) –

    The precision for parsing geometric data.

Returns:

  • List of meshes.
load_urdf ¤
load_urdf(file: str)

Load a URDF file from a Github support package repository.

Parameters:

  • file (str) –

    File name. Following convention, the file should reside inside a urdf folder.

LocalPackageMeshLoader ¤

LocalPackageMeshLoader(path: str, support_package: str | None = None)

Loads suport package resources stored locally.

Attributes:

  • path

    Path where the package is stored locally.

  • support_package

    Name of the support package containing URDF, Meshes and additional assets, e.g. abb_irb4400_support.

Functions¤

build_path ¤
build_path(*path_parts: str) -> str

Returns the building path.

Parameters:

  • *path_parts (str, default: () ) –

    The additional foldernames that construct the path.

can_load_mesh ¤
can_load_mesh(url: str) -> bool

Determine whether this loader can load a given mesh URL.

Parameters:

  • url (str) –

    Mesh URL.

Returns:

  • bool

    True if the URL uses the package:// scheme and the package name matches the specified in the constructor and the file exists locally, otherwise False.

load_meshes ¤
load_meshes(url: str, precision: int | None = None) -> list[Mesh]

Load meshes from the given URL.

A single mesh file can contain multiple meshes depending on the format.

Parameters:

  • url (str) –

    Mesh URL

  • precision (int | None, default: None ) –

    The precision for parsing geometric data.

Returns:

  • List of meshes.
load_urdf ¤
load_urdf(file: str)

Load a URDF file from local storage.

Parameters:

  • file (str) –

    File name. Following convention, the file should reside inside a urdf folder.

Functions¤

mesh_import ¤

mesh_import(name, file, precision=None)

Internal function to load meshes using the correct loader.

Name and file might be the same but not always, e.g. temp files.