Files
I150/srcs/RobotNet10/Shared/RobotNet10.Shared/Sensor/PointCloud2.cs
2026-07-03 16:37:12 +07:00

133 lines
3.3 KiB
C#

namespace RobotNet10.Shared.Sensor;
/// <summary>
/// PointCloud2 message (sensor_msgs/PointCloud2)
/// This message holds a collection of N-dimensional points, which may
/// contain additional information such as normals, intensity, etc. The
/// point data is stored as a binary blob, its layout described by the
/// contents of the "fields" array.
/// </summary>
public struct PointCloud2
{
/// <summary>
/// Header with timestamp and frame ID
/// </summary>
public Header Header { get; set; }
/// <summary>
/// Height of the cloud
/// </summary>
public uint Height { get; set; }
/// <summary>
/// Width of the cloud
/// </summary>
public uint Width { get; set; }
/// <summary>
/// Describes the channels and their layout in the binary data blob
/// </summary>
public PointField[] Fields { get; set; }
/// <summary>
/// Is this data bigendian?
/// </summary>
public bool IsBigendian { get; set; }
/// <summary>
/// Length of a point in bytes
/// </summary>
public uint PointStep { get; set; }
/// <summary>
/// Length of a row in bytes
/// </summary>
public uint RowStep { get; set; }
/// <summary>
/// Actual point data, size is (row_step*height)
/// </summary>
public byte[] Data { get; set; }
/// <summary>
/// True if there are no invalid points
/// </summary>
public bool IsDense { get; set; }
/// <summary>
/// Default constructor
/// </summary>
public PointCloud2()
{
Header = new Header();
Height = 0;
Width = 0;
Fields = Array.Empty<PointField>();
IsBigendian = false;
PointStep = 0;
RowStep = 0;
Data = Array.Empty<byte>();
IsDense = false;
}
}
/// <summary>
/// PointField message (sensor_msgs/PointField)
/// This message holds the description of one point entry in the PointCloud2 message format
/// </summary>
public struct PointField
{
/// <summary>
/// Point field name constants
/// </summary>
public const string NameX = "x";
public const string NameY = "y";
public const string NameZ = "z";
public const string NameRgb = "rgb";
public const string NameIntensity = "intensity";
/// <summary>
/// Name of field
/// </summary>
public string Name { get; set; }
/// <summary>
/// Offset from start of point struct
/// </summary>
public uint Offset { get; set; }
/// <summary>
/// Datatype enumeration constants
/// </summary>
public const byte Int8 = 1;
public const byte Uint8 = 2;
public const byte Int16 = 3;
public const byte Uint16 = 4;
public const byte Int32 = 5;
public const byte Uint32 = 6;
public const byte Float32 = 7;
public const byte Float64 = 8;
/// <summary>
/// Datatype enumeration (Datatype constants)
/// </summary>
public byte Datatype { get; set; }
/// <summary>
/// How many elements in field
/// </summary>
public uint Count { get; set; }
/// <summary>
/// Default constructor
/// </summary>
public PointField()
{
Name = string.Empty;
Offset = 0;
Datatype = 0;
Count = 0;
}
}