zijiechenrobotics / ig_lio

iG-LIO: An Incremental GICP-based Tightly-coupled LiDAR-inertial Odometry
GNU General Public License v2.0
402 stars 52 forks source link

PCD Scan Save #36

Closed kushantp58 closed 4 months ago

kushantp58 commented 4 months ago

How do you save scans like you could do it for LIO SLAMs ?

I tried using this in config.yaml - pcd_save: interval: -1 pcd_save_en: true

Didn't work, any help would be appreciated !

kushantp58 commented 4 months ago

Never mind, figured it out using pcl-ros. Thanks !!

alwynmathew commented 3 months ago

@kushantp58, how did you save the scan?

kushantp58 commented 3 months ago

So you use pcl_ros to save it .

  1. Install it using sudo apt intall ros-noetic-pcl-ros .
  2. Start the slam and use this: rosrun pcl_ros pointcloud_to_pcd input:=/current_scan
  3. This will save pcd scans in that particular directory
  4. Now you will have all the scans, you can either merge them to get a .ply file (I've written a script for this if you want)
alwynmathew commented 3 months ago

Thank you @kushantp58. I did record each scan with pcl_ros, but will the resultant merged scan have redundant points? Please share the script.

kushantp58 commented 3 months ago

``import open3d as o3d import os , re

check the current working directory

print("Current working directory: ", os.getcwd()) print("Changing working directory to the data folder ...") print("Testing IO for point cloud ...") folder = "/home/kuspatel/data/2024_07_09_15_38_45/2024_07_09_15_38_45/ig_lio/scans/" #replace this with your folder name

iterate through directory

pcds = [] for file in os.listdir(folder): if file.endswith(".pcd"): print("Reading file: ", file) pcds.append(file)

print("Saving concatenated point cloud ...")

convert it into a single point cloud

pd = o3d.geometry.PointCloud() for file in pcds: pcd_temp = o3d.io.read_point_cloud(folder + file) pd += pcd_temp

save the point cloud to a ply file

o3d.io.write_point_cloud(folder + "merged.ply", pd) ``