Crate ycbust

Crate ycbust 

Source
Expand description

§ycbust

A library for downloading and extracting the YCB (Yale-CMU-Berkeley) Object and Model Set for 3D rendering and robotic simulation environments.

§Example

use ycbust::{download_ycb, Subset, DownloadOptions};
use std::path::Path;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Download representative objects with default options
    download_ycb(
        Subset::Representative,
        Path::new("/tmp/ycb"),
        DownloadOptions::default(),
    ).await?;
    Ok(())
}

§Lower-level API

For more control, you can use the individual functions:

use ycbust::{fetch_objects, get_tgz_url, download_file, extract_tgz};
use reqwest::Client;
use std::path::Path;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::new();

    // Fetch available objects
    let objects = fetch_objects(&client).await?;
    println!("Available objects: {:?}", objects);

    // Get URL for a specific object
    let url = get_tgz_url("003_cracker_box", "google_16k");

    // Download and extract
    let dest = Path::new("/tmp/ycb/003_cracker_box_google_16k.tgz");
    download_file(&client, &url, dest, true).await?;
    extract_tgz(dest, Path::new("/tmp/ycb"), true)?;

    Ok(())
}

Structs§

DownloadOptions
Options for downloading YCB objects.

Enums§

Subset
Subset of objects to download.

Constants§

BASE_URL
Base URL for the YCB dataset on S3.
OBJECTS_URL
URL for the objects index JSON file.
REPRESENTATIVE_OBJECTS
Representative subset of 3 commonly used objects.
TEN_OBJECTS
Subset of 10 commonly used objects.

Functions§

download_file
Downloads a file from a URL to the specified destination path.
download_ycb
High-level function to download YCB objects.
extract_tgz
Extracts a .tgz (gzip-compressed tar) archive to the specified output directory.
fetch_objects
Fetches the list of available objects from the YCB dataset.
get_subset_objects
Returns the list of objects for a given subset without fetching from the network.
get_tgz_url
Constructs the download URL for a specific object and file type.
url_exists
Checks if a URL exists by sending a HEAD request.