2
2

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 3 years have passed since last update.

Ubuntu 20.04へのROS2とturtlebot3のインストール及び使用方法

Last updated at Posted at 2021-08-13

#はじめに
色々あってubuntu20.04にしたので、ros2の環境構築のための備忘録

#ROS2(Foxy)一式のインストール

sudo apt update && sudo apt install curl gnupg2 lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt install ros-foxy-desktop
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python3-colcon-common-extensions
sudo apt install python3-argcomplete

#ワークスペース作成+動作確認

mkdir -p ~/ros2_ws/src
cd ros2_ws/
colcon build

下記のように別々のターミナルで実行

tuner@tuner-MB-K700:~/ros2_ws$ ros2 run demo_nodes_cpp talker
[INFO] [1628862628.345402415] [talker]: Publishing: 'Hello World: 1'
[INFO] [1628862629.345713385] [talker]: Publishing: 'Hello World: 2'
[INFO] [1628862630.345504745] [talker]: Publishing: 'Hello World: 3'
[INFO] [1628862631.345552208] [talker]: Publishing: 'Hello World: 4'
[INFO] [1628862632.345710889] [talker]: Publishing: 'Hello World: 5'
tuner@tuner-MB-K700:~/ros2_ws$ ros2 run demo_nodes_py listener
[INFO] [1628862618.637940183] [listener]: I heard: [Hello World: 21]
[INFO] [1628862619.624764459] [listener]: I heard: [Hello World: 22]
[INFO] [1628862620.626850078] [listener]: I heard: [Hello World: 23]

#turtlebot3用の環境構築

sudo apt install gazebo11 ros-foxy-gazebo-ros-pkgs
sudo apt install ros-foxy-dynamixel-sdk
sudo apt install ros-foxy-cartographer
sudo apt install ros-foxy-cartographer-ros
sudo apt install ros-foxy-navigation2
sudo apt install ros-foxy-nav2-bringup
sudo apt install ros-foxy-turtlebot3-msgs
sudo apt install ros-foxy-turtlebot3

mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws/src
git clone -b foxy-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/turtlebot3_ws
colcon build --symlink-install

#起動1

source install/setup.bash 
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py 

#起動2(別ターミナルにて)

source install/setup.bash 
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_navigation2    navigation2.launch.py   

初期状態は下記のように初期位置が不明なため,お馴染みの2D Pose Estimateにてgazeboの位置と同じ場所にrivizで指定すると、、、

image.png

上部のtabのNavigation2 Goalにて自律移動可能

image.png

見た目的な違いといえば
ros1と違いがgazebo上にてlidarの照射範囲が見えるようになった。
              +
デフォルトとしてslam-gmappingではなくcartographerを使用している。

まだまだ、味見程度なので色々試したい。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?