robotics_signals/sensors/
point_cloud.rs

1use cdds_derive::*;
2use cyclonedds_rs::*;
3use serde_derive::{Deserialize, Serialize};
4
5use crate::standard::Header;
6
7/// This message holds a collection of N-dimensional points, which may
8/// contain additional information such as normals, intensity, etc. The
9/// point data is stored as a binary blob, its layout described by the
10/// contents of the "fields" array.
11///
12/// The point cloud data may be organized 2d (image-like) or 1d (unordered).
13/// Point clouds organized as 2d images may be produced by camera depth sensors
14/// such as stereo or time-of-flight.
15#[repr(C)]
16#[derive(Serialize, Deserialize, Topic)]
17pub struct PointCloud {
18    /// Time of sensor data acquisition, and the coordinate frame ID (for 3d points).
19    pub header: Header,
20
21    /// 2D structure of the point cloud. If the point cloud is
22    /// unordered, height is 1 and width is the length of the point cloud.
23    pub height: u32,
24    pub width: u32,
25
26    /// Describes the channels and their layout in the binary data blob.
27    pub fields: Vec<PointField>,
28
29    pub is_bigendian: bool,
30    /// length of a point in bytes
31    pub point_step: u32,
32    /// length of a row in bytes
33    pub row_step: u32,
34    /// Point data. size is (row_step*height)
35    pub data: Vec<u8>,
36
37    /// true if there are no invalid points
38    pub is_dense: bool,
39}
40
41#[repr(C)]
42#[derive(Serialize, Deserialize)]
43pub enum PointFieldDataType {
44    Int8,
45    Uint8,
46    Int16,
47    Uint16,
48    Int32,
49    Uint32,
50    Float32,
51    Float64,
52}
53
54#[repr(C)]
55#[derive(Serialize, Deserialize)]
56pub struct PointField {
57    /// name of field
58    pub name: String,
59    /// offset from start of point struct
60    pub offset: u32,
61    pub datatype: PointFieldDataType,
62    pub cound: u32,
63}