Schema Management
Manages JSON schemas and ROS2 message definitions.
tabular2mcap.schemas.jsonschema
Foxglove schema utilities for accessing message definitions.
get_foxglove_jsonschema(schema_name)
Get a Foxglove schema by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_name
|
str
|
Name of the schema (e.g., 'LocationFix', 'Pose') |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Bytes containing the schema definition |
tabular2mcap.schemas.ros2msg
tabular2mcap.schemas.cache
Script to download and cache ROS 2 message definitions from official repositories.
This script downloads the following repositories for a specified ROS 2 distribution: - rcl_interfaces - common_interfaces - geometry2
The downloaded files are cached in the user's cache directory to avoid re-downloading.
download_and_cache_all_repos(distro='jazzy', cache_dir=None)
Download and cache all ROS 2 message definition repositories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distro
|
str
|
ROS 2 distribution name (default: "jazzy") |
'jazzy'
|
cache_dir
|
Path | None
|
Cache directory path (default: uses platformdirs cache) |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if all repositories downloaded successfully, False otherwise |
download_and_cache_repository(repo_name, url, distro, cache_dir)
Download and cache a single repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Name of the repository |
required |
url
|
str
|
URL template for downloading (with {distro_str} placeholder) |
required |
distro
|
str
|
ROS 2 distribution name |
required |
cache_dir
|
Path
|
Cache directory path |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
download_file(url, destination, max_retries=DEFAULT_MAX_RETRIES, initial_backoff=DEFAULT_INITIAL_BACKOFF, backoff_multiplier=DEFAULT_BACKOFF_MULTIPLIER, max_backoff=DEFAULT_MAX_BACKOFF)
Download a file from URL to destination path with retry logic.
Uses exponential backoff for transient failures (network errors, HTTP 5xx).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to download from |
required |
destination
|
Path
|
Local path to save the file |
required |
max_retries
|
int
|
Maximum number of retry attempts (default: 3) |
DEFAULT_MAX_RETRIES
|
initial_backoff
|
float
|
Initial backoff delay in seconds (default: 1.0) |
DEFAULT_INITIAL_BACKOFF
|
backoff_multiplier
|
float
|
Multiplier for backoff after each retry (default: 2.0) |
DEFAULT_BACKOFF_MULTIPLIER
|
max_backoff
|
float
|
Maximum backoff delay in seconds (default: 30.0) |
DEFAULT_MAX_BACKOFF
|
Returns:
| Type | Description |
|---|---|
bool
|
True if download successful, False otherwise |
extract_zip(zip_path, extract_to)
Extract a zip file to the specified directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zip_path
|
Path
|
Path to the zip file |
required |
extract_to
|
Path
|
Directory to extract to |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if extraction successful, False otherwise |
is_repository_cached(repo_name, distro, cache_dir)
Check if a repository is already cached for the given distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_name
|
str
|
Name of the repository |
required |
distro
|
str
|
ROS 2 distribution name |
required |
cache_dir
|
Path
|
Cache directory path |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if repository is cached, False otherwise |
list_cached_repositories(cache_dir=None)
List all cached repositories and their message file counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_dir
|
Path | None
|
Cache directory path (default: uses platformdirs cache) |
None
|