Skip to content

Commit

Permalink
[MINOR] update readme on PIN-SLAM with colorized lidar points
Browse files Browse the repository at this point in the history
  • Loading branch information
Yue Pan committed Aug 27, 2024
1 parent 75aff77 commit 7ee646f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 37 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ conda activate pin
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.7 -c pytorch -c nvidia
```

The commands depend on your CUDA version. You may check the instructions [here](https://pytorch.org/get-started/previous-versions/).
The commands depend on your CUDA version (check it by `nvcc --version`). You may check the instructions [here](https://pytorch.org/get-started/previous-versions/).

### 3. Install other dependency

Expand Down Expand Up @@ -175,6 +175,11 @@ Use `run_demo_sem.yaml` if you want to conduct metric-semantic SLAM using semant
python3 pin_slam.py ./config/lidar_slam/run_demo_sem.yaml -vsm
```

Use `run_kitti_color.yaml` if you want to test PIN-SLAM with the colorized point cloud using also the RGB images:
```
python3 pin_slam.py ./config/lidar_slam/run_kitti_color.yaml kitti 00 -i ./data/kitti_example -vsmd
```

If you are running on a server without an X service (you may first try `export DISPLAY=:0`), then you can turn off the visualization `-v` flag:
```
python3 pin_slam.py ./config/lidar_slam/run_demo.yaml -sm
Expand Down Expand Up @@ -256,7 +261,7 @@ The SLAM results and logs will be output in the `output_root` folder set in the

For evaluation, you may check [here](https://github.com/PRBonn/PIN_SLAM/blob/main/eval/README.md) for the results that can be obtained with this repository on a couple of popular datasets.

The training logs can be monitored via Weights & Bias online if you set the flag `-w`. If it's your first time using [Weights & Bias](https://wandb.ai/site), you will be requested to register and log in to your wandb account. You can also set the flag `-l` to turn on the log printing in the terminal and set the flag `-r` to turn on the visualization logging by [rerun](https://github.com/rerun-io/rerun).
The training logs can be monitored via Weights & Bias online if you set the flag `-w`. If it's your first time using [Weights & Bias](https://wandb.ai/site), you will be requested to register and log in to your wandb account. You can also set the flag `-l` to turn on the log printing in the terminal and set the flag `-r` to turn on the visualization logging by [rerun](https://github.com/rerun-io/rerun). If you want to get the dense merged point cloud map using the estimated poses of PIN-SLAM, you can set the flag `-p`.

</details>

Expand Down
6 changes: 3 additions & 3 deletions config/lidar_slam/run_kitti_color.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ process:
min_z_m: -3.5
sampler:
surface_sample_range_m: 0.25
surface_sample_n: 4
surface_sample_n: 3
free_sample_begin_ratio: 0.3
free_sample_end_dist_m: 1.0
free_front_sample_n: 2
free_front_sample_n: 4 # 2
neuralpoints:
voxel_size_m: 0.4
feature_dim: 8
Expand All @@ -35,7 +35,7 @@ loss:
ekional_loss_on: True
weight_e: 0.5
continual:
batch_size_new_sample: 1000
batch_size_new_sample: 4000
pool_capacity: 2e7
tracker:
source_vox_down_m: 0.6
Expand Down
14 changes: 3 additions & 11 deletions dataset/dataloaders/apollo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# Copyright (c) 2022 Ignacio Vizzo, Tiziano Guadagnino, Benedikt Mersch, Cyrill
# Stachniss.
# 2024 Yue Pan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -29,19 +28,12 @@

import natsort
import numpy as np
import open3d as o3d
from pyquaternion import Quaternion


class ApolloDataset:
def __init__(self, data_dir: Path, *_, **__):
try:
self.o3d = importlib.import_module("open3d")
except ModuleNotFoundError:
print(
'pcd files requires open3d and is not installed on your system run "pip install open3d"'
)
sys.exit(1)

self.scan_files = natsort.natsorted(glob.glob(f"{data_dir}/pcds/*.pcd"))
self.gt_poses = self.read_poses(f"{data_dir}/poses/gt_poses.txt")
self.sequence_id = os.path.basename(data_dir)
Expand All @@ -57,7 +49,7 @@ def __getitem__(self, idx):
return frame_data

def get_scan(self, scan_file: str):
points = np.asarray(self.o3d.io.read_point_cloud(scan_file).points, dtype=np.float64)
points = np.asarray(o3d.io.read_point_cloud(scan_file).points, dtype=np.float64)
return points.astype(np.float64)

@staticmethod
Expand All @@ -82,4 +74,4 @@ def get_timestamps(points):
y = points[:, 1]
yaw = -np.arctan2(y, x)
timestamps = 0.5 * (yaw / np.pi + 1.0)
return timestamps
return timestamps
10 changes: 1 addition & 9 deletions dataset/dataloaders/helipr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@

class HeLiPRDataset:
def __init__(self, data_dir: Path, sequence: str, *_, **__):
try:
self.o3d = importlib.import_module("open3d")
except ModuleNotFoundError as e:
raise ModuleNotFoundError(
"Open3D is not installed on your system, to fix this either "
'run "pip install open3d" '
"or check https://www.open3d.org/docs/release/getting_started.html"
) from e


self.sequence_id = sequence
self.sequence_dir = os.path.join(data_dir, "LiDAR", self.sequence_id)
scan_files = os.listdir(self.sequence_dir)
Expand Down
6 changes: 4 additions & 2 deletions dataset/dataloaders/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def __init__(self, data_dir, sequence: str, *_, **__):
# Load GT Poses (if available)
if int(sequence) < 11:
self.poses_fn = os.path.join(data_dir, f"poses/{self.sequence_id}.txt")
if not os.path.exists(self.poses_fn):
self.poses_fn = os.path.join(self.kitti_sequence_dir, f"poses.txt")
self.gt_poses = self.load_poses(self.poses_fn)

def __getitem__(self, idx):
Expand Down Expand Up @@ -226,8 +228,8 @@ def persepective_cam2image(self, points, K_mat):
points_proj = np.matmul(K_mat[:3,:3].reshape([1,3,3]), points)
depth = points_proj[:,2,:]
depth[depth==0] = -1e-6
u = np.round(points_proj[:,0,:]/np.abs(depth)).astype(np.int32)
v = np.round(points_proj[:,1,:]/np.abs(depth)).astype(np.int32)
u = np.round(points_proj[:,0,:]/np.abs(depth)).astype(int)
v = np.round(points_proj[:,1,:]/np.abs(depth)).astype(int)

if ndim==2:
u = u[0]; v=v[0]; depth=depth[0]
Expand Down
4 changes: 2 additions & 2 deletions dataset/dataloaders/kitti360.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def persepective_cam2image(self, points, K_mat):
points_proj = np.matmul(K_mat[:3,:3].reshape([1,3,3]), points)
depth = points_proj[:,2,:]
depth[depth==0] = -1e-6
u = np.round(points_proj[:,0,:]/np.abs(depth)).astype(np.int32)
v = np.round(points_proj[:,1,:]/np.abs(depth)).astype(np.int32)
u = np.round(points_proj[:,0,:]/np.abs(depth)).astype(int)
v = np.round(points_proj[:,1,:]/np.abs(depth)).astype(int)

if ndim==2:
u = u[0]; v=v[0]; depth=depth[0]
Expand Down
6 changes: 2 additions & 4 deletions model/neural_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ def __init__(self, config: Config) -> None:

self.device = config.device
self.dtype = config.dtype
self.idx_dtype = (
torch.int64
) # torch.int64/32 does not have much speed difference

self.idx_dtype = torch.int64

self.resolution = config.voxel_size_m

self.buffer_size = config.buffer_size
Expand Down
4 changes: 2 additions & 2 deletions pin_slam.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def run_pin_slam(config_path=None, dataset_name=None, sequence_name=None, seed=N
if config.pgo_on:
print("time for loop detection and PGO (ms):", (T4-T3)*1e3)
print("time for mapping preparation (ms):", (T5-T4)*1e3)
print("time for training (ms):", (T6-T5)*1e3)
print("time for mapping (ms):", (T6-T5)*1e3)

# regular saving logs
if config.log_freq_frame > 0 and (frame_id+1) % config.log_freq_frame == 0:
Expand Down Expand Up @@ -392,7 +392,7 @@ def run_pin_slam(config_path=None, dataset_name=None, sequence_name=None, seed=N
else:
cur_sdf_slice = cur_sdf_slice_h

pool_pcd = mapper.get_data_pool_o3d(down_rate=17, only_cur_data=o3d_vis.vis_only_cur_samples) if o3d_vis.render_data_pool else None # down rate should be a prime number
pool_pcd = mapper.get_data_pool_o3d(down_rate=23, only_cur_data=o3d_vis.vis_only_cur_samples) if o3d_vis.render_data_pool else None # down rate should be a prime number
odom_poses, gt_poses, pgo_poses = dataset.get_poses_np_for_vis()
loop_edges = pgm.loop_edges_vis if config.pgo_on else None
o3d_vis.update_traj(dataset.cur_pose_ref, odom_poses, gt_poses, pgo_poses, loop_edges)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ rich==12.5.1
roma==1.5.0
rospkg==1.5.1
scikit-image==0.21.0
wandb==0.17.0
wandb==0.17.0
opencv-python
2 changes: 1 addition & 1 deletion scripts/download_kitti_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mkdir -p data
cd data

echo Downloading KITTI odometry dataset, sequence 00 subset, first 100 frames ...
wget -O kitti_example.tar.gz -c https://uni-bonn.sciebo.de/s/KwOuBiPZi8vSz2O/download
wget -O kitti_example.tar.gz -c https://uni-bonn.sciebo.de/s/Ycl28f1Cppghvjm/download

echo Extracting dataset...
tar -xvf kitti_example.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import subprocess
import sys
import time
import warnings
from datetime import datetime
from pathlib import Path
from typing import List
Expand Down Expand Up @@ -40,6 +41,8 @@ def setup_experiment(config: Config, argv=None, debug_mode: bool = False):
os.environ["CUDA_VISIBLE_DEVICES"] = str(config.gpu_id)
ts = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") # begining timestamp

warnings.filterwarnings("ignore", category=FutureWarning)

run_name = config.name + "_" + ts # modified to a name that is easier to index

run_path = os.path.join(config.output_root, run_name)
Expand Down

0 comments on commit 7ee646f

Please # to comment.