LoginSignup
7
6

More than 3 years have passed since last update.

ubuntu20.04・ROS NoeticでRTAB-MAPを動かす(1)

Posted at

はじめに

ubuntu20.04LTS上のROS Noeticでrtabmap_rosを動かしたのでその方法をメモしました。

動作環境

以下の環境で動作確認しました。

項目
CPU Ryzen5
OS Ubuntu20.04LTS
ROS Noetic Ninjemys

ROS Noeticのインストール

すでにROSが入っている方は飛ばしてください。

aptへROSのダウンロード先の登録

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

公開鍵の取得

$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

インストール

$ sudo apt update
$ sudo apt install ros-noetic-desktop-full

環境変数の設定

$ echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc

ROSパッケージインストーラのインストール

$ sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

rosdepの初期化

$ sudo rosdep init
$ rosdep update

ワークスペースの作成

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make

RTAB-MAPのインストール (aptから)

以下コマンドでインストールします。

sudo apt install ros-noetic-rtabmap-ros ros-noetic-rtabmap

RTAB-MAPのインストール (ソースからビルド)

なぜか自分の環境ではaptからインストールすると後述のデモが動かなかったのでソースからビルドしました。

以下のBuild from sourceを参照
https://github.com/introlab/rtabmap_ros

以下でRTAB-MAP本体のインストールとビルド

$ cd ~
$ git clone https://github.com/introlab/rtabmap.git rtabmap
$ cd rtabmap/build
$ cmake .. 
$ make
$ sudo make install

rtabmap_rosのインストールとビルド

$ cd ~/catkin_ws
$ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
$ catkin_make -j1

デモの実行

まず以下からrosbagをダウンロードします。
demo_mapping.bag

ターミナルを開いて以下を実行

roslaunch rtabmap_ros demo_robot_mapping.launch 

別のターミナルでrosbagをダウンロードしたディレクトリで以下を実行

rosbag play --clock demo_mapping.bag

このようなGUI画面が表示されます。
Screenshot from 2021-01-14 23-41-00.png

GUI画面の見方は以下記事を参考にしてください。
RTABMAPの使い方

次にデモ実行時のrqt_graphを見ていきます。

rqt_graph

rosgraph.png

rtabmapには

  • /jn0/base_scan
  • /tf
  • /data_throttled_image/compressed
  • /data_throttled_image_depth/compressedDepth,
  • /data_throttled_camera_info

のトピックが入力されています。
/rtabmap/rtabmapvizというのはGUI画面のノードです。

/data_throttled_image/compressedはRGB画像、/data_throttled_image_depth/compressedDepthはDepth画像、/data_throttled_camera_infoはカメラパラメータです。
/jn0/base_scanトピックはLaserScan型で2DLiDARのスキャンを入力しているようです。

最後に

次回はRealSense L515を使用して環境のSLAMを行います。
aptからrtabmap_rosをインストールしてデモが動いた方はぜひコメントください。

参考

rtabmap_ros - ROS Wiki
http://wiki.ros.org/rtabmap_ros

RTABMAPの使い方
https://qiita.com/k65c1/items/7a4df58b50a587fad3e2

RealsenseでSLAMをする。
https://qiita.com/k65c1/items/0d9039c021ecbb26b04e

RTABMAPをよむ 前篇
https://qiita.com/ohtt/items/b3c00a62757244a6e16c

RTAB-Mapのデモを動かす
https://veloart-intelligence.com/blog/run-rtab-map-demo/

7
6
1

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
7
6