$npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-point-cloud-file-ioRead and write 3-D point cloud data using Lidar Toolbox file I/O. Covers PLY, PCD, LAS/LAZ, PCAP (Velodyne/Ouster/Hesai), E57, and IDC (Ibeo) formats. Use when loading point clouds from disk, saving to disk, choosing the correct reader or writer for a file format, extracting or p
| 1 | # Point Cloud File I/O |
| 2 | |
| 3 | Read and write 3-D point cloud data in MATLAB using Lidar Toolbox file I/O functions, covering PLY, PCD, LAS/LAZ, sensor PCAP, E57, and IDC (Ibeo) formats. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Loading a point cloud file from disk into a `pointCloud` object |
| 8 | - Saving a `pointCloud` object to disk in any supported format |
| 9 | - Deciding which reader or writer function to use for a given file format |
| 10 | - Reading LAS/LAZ files with selective filtering (ROI, classification, GPS time) |
| 11 | - Extracting or preserving lidar point attributes (classification, GPS timestamps, scan angle) |
| 12 | - Reading Velodyne, Ouster, or Hesai PCAP sensor recordings frame-by-frame |
| 13 | - Reading multi-scan E57 files with indexed access |
| 14 | - Reading Ibeo IDC sensor recordings with message-based access |
| 15 | - Converting between point cloud formats (e.g., LAS to PLY, PCD to LAZ) |
| 16 | |
| 17 | ## When NOT to Use |
| 18 | |
| 19 | - Streaming live sensor data in real time (use `velodynelidar`, `ousterlidar`, `sicklidar`) |
| 20 | - Processing or filtering point clouds after reading (use `pcdownsample`, `pcdenoise`) |
| 21 | - Reading or writing surface meshes (use `readSurfaceMesh`, `writeSurfaceMesh`) |
| 22 | - Saving point cloud variables to MAT-files (use `save`) |
| 23 | - Visualizing point clouds (use `pcshow`, `pcplayer`, `pcviewer`) |
| 24 | |
| 25 | ## Must-Follow Rules |
| 26 | |
| 27 | 1. **Route by file extension, not by habit** — `pcread` ONLY supports `.ply` and `.pcd` files. For `.las`/`.laz` use `lasFileReader` + `readPointCloud`. For `.pcap` use the sensor-specific file reader (`velodyneFileReader`, `ousterFileReader`, or `hesaiFileReader`). For `.e57` use `e57FileReader`. Calling `pcread` on a LAS or PCAP file produces an error, not a warning. Similarly, `pcwrite` ONLY writes PLY and PCD — for LAS/LAZ output use `lasFileWriter` + `writePointCloud`. |
| 28 | |
| 29 | 2. **PCAP file readers require a mandatory device identifier — never guess it** — `velodyneFileReader` requires a `DeviceModel` string (e.g., `"HDL32E"`). `hesaiFileReader` requires a `DeviceModel` string (e.g., `"PandarXT32"`). `ousterFileReader` requires a `CalibrationFile` path (JSON). If the user has not specified the device model or calibration file, ASK — do not assume a default. There is no default value; omitting it causes an error. |
| 30 | |
| 31 | 3. **Use two-output syntax to get point attributes from LAS/LAZ** — `[ptCloud, ptAttributes] = readPointCloud(reader)` returns a `lidarPointAttributes` object containing Classification, GPSTimeStamp, LaserReturn, NumReturns, ScanAngle, and more. The single-output form discards these attributes permanently. Intensity is on the `pointCloud` object (`.Intensity` property), NOT on `lidarPointAttributes`. |
| 32 | |
| 33 | 4. **Preserve attributes with three-argument writePointCloud** — `writePointCloud(writer, ptCloud, ptAttributes)` preserves Classification, GPSTimeStamp, and other lidar attributes in LAS/LAZ output. The two-argument form `writePointCloud(writer, ptCloud)` discards all attributes. If the user has attributes from `lasFileReader`/`readPointCloud`, always pass them through. |
| 34 | |
| 35 | 5. **PLY only supports ascii and binary encoding** — Calling `pcwrite(ptCloud, "file.ply", Encoding="compressed")` throws an error. Only `"ascii"` and `"binary"` are valid for PLY. The `"compressed"` encoding is exclusive to PCD format. Defaults (R2026a+): PLY=`"binary"`, PCD=`"compressed"`. |
| 36 | |
| 37 | 6. **Always use string syntax** — Use double-quoted strings (`"text"`) for all literal text arguments (filenames, device models, encoding values, Name=Value values). Use `Name=Value` syntax for all name-value pairs. Never use character vectors (`'text'`) or legacy `'Name','Value'` pair syntax. |
| 38 | |
| 39 | ### Preflight Procedure |
| 40 | |
| 41 | 1. List MATLAB functions to call |
| 42 | 2. Check `references/INDEX.md` for each (function-level + task-level tables) |
| 43 | 3. Read required quick-ref files |
| 44 | 4. State at response top: `Preflight: quick-ref/xxx.md, quick-ref/yyy.md` (or `Preflight: none required`) |
| 45 | |
| 46 | ## Key Functions |
| 47 | |
| 48 | | Function | Purpose | Format | Key Constraint | |
| 49 | |---|---|---|---| |
| 50 | | `pcread` | Read point cloud from file | PLY, PCD | Single call, returns `pointCloud` | |
| 51 | | `pcwrite` | Write point cloud to file | PLY, PCD | Encoding varies by format | |
| 52 | | `lasFileReader` | Create LAS/LAZ reader object | LAS, LAZ | Two-step: create reader, then `readPointCloud` | |
| 53 | | `lasFileWriter` | Create LAS/LAZ writer object | LAS, LAZ | Two-step: create writer, then `writePointCloud` | |
| 54 | | `velodyneFileReader` | Create Velodyne PCAP reader | PCAP | Mandatory `DeviceModel` (2nd arg) | |
| 55 | | `ousterFileReader` | Create Ouster PCAP reader | PCAP | Mandatory `Cali |