6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

gradSLAMやーる(gradSLAM0.0.1、Python3.6、CUDA10.2、PyTorch1.7.0)

Last updated at Posted at 2020-11-09

はじめに

gradSLAMやっていきます。

開発環境

  • Windows 10 PC
  • Anaconda
  • Python 3.6
  • PyTorch 1.7.0
  • CUDA 10.2
  • gradSLAM 0.0.1

導入

1.Anaconda promptを開き、python3.6環境を作成します

conda create -n py36 python=3.6
conda activate py36

2.PyTorchをインストールします

pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

3.CUDA Toolkit 10.2をインストールします

image.png

4.chamferdistをクローンし、インストールします

cd chamferdist
pip install .

5.gradSLAMをクローンし、インストールします

cd gradslam
pip install -e .

image.png

6.TUM RGBD Datasetをダウンロードし、examplesフォルダにdataset/tumフォルダを作成し、そこに置きます

image.png

image.png

7.次のコードを実行してみましょう!

import open3d as o3d
import torch
from torch.utils.data import DataLoader

from gradslam import RGBDImages
from gradslam.slam import PointFusion, ICPSLAM
from gradslam.datasets import ICL, TUM

# Dataset to use
dataset_name = "tum"  # "icl", "tum"

# Path to the dataset directory
dataset_path = "./dataset/tum/rgbd_dataset_freiburg1_xyz"

# Odometry method to use
odometry = "gradicp"  # "gt", "icp", "gradicp"

# select device
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")

# load dataset
Dataset = ICL if dataset_name == "icl" else TUM
dataset = Dataset(dataset_path, seqlen=80, height=240, width=320)
loader = DataLoader(dataset=dataset, batch_size=2)
colors, depths, intrinsics, poses, *_ = next(iter(loader))

# create rgbdimages object
rgbdimages = RGBDImages(colors, depths, intrinsics, poses, channels_first=False)

# visualize rgbdimages
fig1 = rgbdimages.plotly(0)
fig1.update_layout(autosize=False, height=720, width=500).show()

# SLAM
slam = PointFusion(odom=odometry, dsratio=4, device=device)
pointclouds, recovered_poses = slam(rgbdimages)

# Plotly visualization
fig2 = pointclouds.plotly(0).update_layout(autosize=False, height=600)
fig2.show()

# Open3d visualization
o3d.visualization.draw_geometries([pointclouds.open3d(0)])

odometryをgradicpを指定、rgbd_dataset_freiburg1_xyzデータセットで80フレーム読み込みSLAMる。画像サイズは幅320×高240。

8.結果です

読み込んだRGBD画像が見れます。

生成されたグローバルマップが見れます。

Open3Dでもグローバルマップが見れます。

お疲れ様でした。

追記 20210728

gradSLAM 0.1.0

Pytorchのインストール

pip3 install torch==1.9.0+cu102 torchvision==0.10.0+cu102 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

cd chamferdist
pip install .

pip install gradslam
Failed to build chamferdist

VisualStudioが必要
https://mebee.info/2020/07/18/post-13597/

visual studio 2019 community
https://visualstudio.microsoft.com/ja/downloads/

image.png

CUDA10.2インストール

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?