Module pcd_rs::writer

source ·
Expand description

Types for writing PCD data.

Writer lets you write points sequentially to PCD file or writer given by user. The written point type must implement PcdSerialize trait. See record moduel doc to implement your own point type.

use anyhow::Result;
use pcd_rs::{DataKind, PcdSerialize, Writer, WriterInit};
use std::path::Path;

#[derive(PcdSerialize)]
pub struct Point {
    x: f32,
    y: f32,
    z: f32,
}

fn main() -> Result<()> {
    let mut writer: Writer<Point, _> = WriterInit {
        height: 300,
        width: 1,
        viewpoint: Default::default(),
        data_kind: DataKind::Ascii,
        schema: None,
    }
    .create("test_files/dump.pcd")?;

    let point = Point {
        x: 3.14159,
        y: 2.71828,
        z: -5.0,
    };

    writer.push(&point)?;
    writer.finish()?;


    Ok(())
}

Structs§

Type Aliases§

  • The DynReader struct writes points with schema determined in runtime.