SLAM（Jetson nano＆ROS melodic）動かしてみた^^

#SLAM（Jetson nano＆ROS melodic）^^

Jetson nano＆ROS melodicでSLAM動かしてみました！！！
壊れたとき用のメモです。。。３回壊してます。。。。^^!!!!!!
#SLAMとは
>SLAM（スラム）とは、自己位置推定と環境地図作成を同時に行うことを言う。
正式名称は、Simultaneous Localization and Mapping。
https://ja.wikipedia.org/wiki/SLAM

#動かし方
主にSLAMは@protocol1964 さんの記事を参考にしています。こちらからどうぞ！！！
[ROS MelodicでTurtlebot3をGazeboで動かしてついでにSLAMする](https://qiita.com/protocol1964/items/1e63aebddd7d5bfd0d1b)
私はただただJetson nanoでしてるだけです^^

#ROSインストール

こちらにまとめております。
[Jetson nano ROS(Melodic)インストール〜Gazeboまで](https://qiita.com/MeRT/items/aaaa6c96cd742c1e4716)


#パッケージ

```
sudo apt-get install ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-navigation'
```
#環境構築
ワークスペース

```
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ~/catkin_ws
```
クローン。。。昔、リボーンみてた。

```
$ cd ~/catkin_ws/src
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_gazebo_plugin.git
```
最後はビルド！

```
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash
```
#Rviz
```
$ export TURTLEBOT3_MODEL=burger
$ roslaunch turtlebot3_fake turtlebot3_fake.launch
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
```
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">【Jetson nano＆ROS Turtlebot3】<br>かわいい！！！ <a href="https://t.co/OwhZaGiidE">pic.twitter.com/OwhZaGiidE</a></p>&mdash; MeRT(ルット)@社会人博士奮闘中 (@MeRTcooking) <a href="https://twitter.com/MeRTcooking/status/1188480167812853760?ref_src=twsrc%5Etfw">October 27, 2019</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

#Gazebo
```
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
```

<blockquote class="twitter-tweet"><p lang="pl" dir="ltr">【Jetson nano＆Gazebo】<br>Hello Gazebo! <a href="https://t.co/fIswPCcYBQ">pic.twitter.com/fIswPCcYBQ</a></p>&mdash; MeRT(ルット)@社会人博士奮闘中 (@MeRTcooking) <a href="https://twitter.com/MeRTcooking/status/1188824681035386880?ref_src=twsrc%5Etfw">October 28, 2019</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

これでたら

```
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid
```

これ

```
$ export LC_ALL=C; unset LANGUAGE
```
#gmapping

クローン。今回は真面目に。

```
$ cd ~/catkin_ws/src
$ git clone https://github.com/ros-perception/slam_gmapping.git
$ git clone https://github.com/ros-perception/openslam_gmapping.git
$ git clone https://github.com/ros-planning/navigation_msgs.git
$ git clone https://github.com/ros-planning/navigation.git
$ git clone https://github.com/ros/geometry2.git
```


ビルド

```
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash
```

#いざ、動作確認へ！
Gazeboとteleopコントローラ

###ターミナル１

```
cd ~/catkin_ws
source ~/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch
```

###ターミナル2

```
cd ~/catkin_ws
source ~/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
```

###ターミナル3

gmapping

```
cd ~/catkin_ws
source ~/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
```
よいしょーーーーー！！！！！！


5V2Aでもなんとか、、、

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/351913/c7879cae-08f1-7fbf-1402-2d9fc37812d5.png)

##CPU・メモリ


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/351913/e676b5ac-3477-89dc-5e2a-13d4746872e2.png)

あらま。。。ご参考までに。。。




#参考文献


[ROS MelodicでTurtlebot3をGazeboで動かしてついでにSLAMする](https://qiita.com/protocol1964/items/1e63aebddd7d5bfd0d1b)

これはMeRT（ルット）。
[Jetson nano ROS(Melodic)インストール〜Gazeboまで](https://qiita.com/MeRT/items/aaaa6c96cd742c1e4716)