> For the complete documentation index, see [llms.txt](https://idminer.gitbook.io/robotis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://idminer.gitbook.io/robotis/part-1-turtlebot3/6.-she-ding/untitled/untitled-1/untitled-2-1.md).

# 6.2.1.1. 安裝 Linux (Ubuntu MATE)

**1) 在 TB3 的 SBC 上安裝 Ubuntu MATE**

{% hint style="info" %}
警示: **Ubuntu Mate** 目前還不支持 Raspberry Pi 3 B+ 板。如果你使用此塊板，請使用 **Raspbian** 方法安裝。
{% endhint %}

{% hint style="info" %}
警示: SD 卡的空白容量應大於 8 GB 才能在 Raspberry Pi 3 上安裝 Linux(Ubuntu MATE)。
{% endhint %}

**\[Remote PC 端]** 從下方的連結下載樹莓派 Pi 3 用的 `Ubuntu MATE 16.04` 映像檔到電腦上.

* [Direct download link](https://ubuntu-mate.org/raspberry-pi/ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz)

**\[Remote PC 端]** 從下載的 image 映像檔來安裝 Ubuntu MATE 到 MicroSD卡上, 建議使用`GNOME Disks`工具的`Restore Disk Image...` 選項, 因為其原生支援 XZ compressed images 映像檔.

```
$ sudo apt-get install gnome-disk-utility
```

* 參考 [Youtube 安裝教學影片](https://www.youtube.com/watch?time_continue=1\&v=V_6GNyL6Dac)

{% hint style="info" %}
雖然建議使用 GNOME Disks 工具，但也可以用其他方法，如使用 Linux 上的 ddrescue 方法。在 Windows 上也可以使用   [Win32 Disk Imager](https://sourceforge.net/projects/win32diskimager/) 方法。
{% endhint %}

```
$ sudo apt-get install gddrescue xz-utils
$ unxz ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz
$ sudo ddrescue -D --force ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img /dev/sdx
```

**2) 在 TB3 的 SBC 單板電腦上安裝 ROS 機器人作業系統**

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-Lkb2PAr9FdhhI1-FMd4%2F-Lkb6RV1TN9y0siu877N%2Flogo_ros.png?alt=media&amp;token=e5ff96a7-6175-4c7c-8ab5-55d235cd0398" alt=""></div>

{% hint style="info" %}
備註: 預設 SBC 是樹莓派 3, 大約需花 1 – 2 hrs 來安裝 ROS 及 TurtleBot3 相關套件, 視你的網路環境而定
{% endhint %}

&#x20;**\[TurtleBot 端]** 使用下方簡單的安裝腳本文件，來安裝 ROS。安裝好 ROS 後，請將 TurtleBot3 SBC 重開機。 **小提示**: Ubuntu 的 Terminal (終端機)可以在螢幕左上方的 Search 圖示找到. 快捷鍵可以使用  `Ctrl`-`Alt`-`T`.

```
$ sudo apt-get update
$ sudo apt-get upgrade
$ wget https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic_rp3.sh && chmod 755 ./install_ros_kinetic_rp3.sh && bash ./install_ros_kinetic_rp3.sh
```

{% hint style="info" %}
NOTE: 要知道安裝了那些套件，可以看看這個連結， [install\_ros\_kinetic\_rp3.sh](https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic_rp3.sh)
{% endhint %}

如果喜歡手動安裝，可參考以下連結。

* &#x20;[手動安裝 ROS Kinetic 版](http://wiki.ros.org/kinetic/Installation/Ubuntu)

**3) 在 TB3 的 SBC 單板電腦樹莓派 3 上安裝 ROS 套件**\
下一步是安裝控制 TB3 的相關 ROS 套件

**\[TurtleBot 端]** 從 github 下載套件

```
$ cd ~/catkin_ws/src
$ git clone https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
```

{% hint style="info" %}
&#x20;備註：如果要用 Raspberry Pi 攝影機，請先參考了解 [Raspberry Pi Camera 附錄](http://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_raspi_cam/#raspberry-pi-camera)頁面
{% endhint %}

**\[TurtleBot 端]** 刪除TB3 SBC 不需要的套件

```
$ cd ~/catkin_ws/src/turtlebot3
$ sudo rm -r turtlebot3_description/ turtlebot3_teleop/ turtlebot3_navigation/ turtlebot3_slam/ turtlebot3_example/
```

**\[TurtleBot 端]** 安裝相關套件

```
$ sudo apt-get install ros-kinetic-rosserial-python ros-kinetic-tf
```

**\[TurtleBot 端]** 安裝套件後，請重啟 Raspberry Pi 3

**\[TurtleBot 端]** build package

```
$ source /opt/ros/kinetic/setup.bash
$ cd ~/catkin_ws && catkin_make -j1
```

如果`catkin_make` 指令完成沒有出錯，則使用 TurtleBot3 SBC 的準備工作就完成了。

**4) USB 設定**\
**\[TurtleBot 端]** 以下指令允許從 USB 埠連上 OpenCR 控制板，無須管理員權限

```
$ rosrun turtlebot3_bringup create_udev_rules
```

&#x20;**5) 網路設定**

![](https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-Lkb2PAr9FdhhI1-FMd4%2F-LkbFvx7kEJ1CjH1BAs4%2Fnetwork_configuration.png?alt=media\&token=05abd2db-657a-49f4-966c-eb1a9caa0a14)

ROS 需要知道 IP 位址以便溝通 TurtleBot3 及 remote PC。Remote PC 跟TB3 需要在相同區段的 Wifi 網域連接。

**\[TurtleBot 端]** 在 TurtleBot3 SBC 單板電腦的 terminal 視窗, 輸入下列指令來找出 TurtleBot3 的 IP

```
$ ifconfig
```

下圖紅色方格內的文字, 顯示 TurtleBot3 SBC 單板電腦的 IP 位址

![](https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LkhSdZ2zI0zehUyfbE3%2F-LkhTO0KfRpWsKa-ro8T%2Fnetwork_configuration4.png?alt=media\&token=69e52919-cc1d-497f-8c43-1829d6df6cfd)

接著輸入以下的指令

```
$ nano ~/.bashrc
```

按`alt+/` 來結束該行文件。

參考下圖紅色方格. 首先將 ROS\_MASTER\_URI 位址的 localhost, 替換為在 **6.1. Remote PC 的設定**的 **6.1.4. 網路連線設定**網頁，所取得的 remote PC 端(你的桌電或筆電)的 IP 位址. 接著將 ROS\_HOSTNAME IP 位址的 localhost, 替換為上面 terminal 視窗所取得的 TB3 SBC 單板電腦的 IP 位址.

![](https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LkhSdZ2zI0zehUyfbE3%2F-LkhWRqJzABQX7v6eJFe%2Fnetwork_configuration5.png?alt=media\&token=fc47b743-d45d-412b-94dc-e4f31ff4f884)

接著 source bashrc 指令

```
$ source ~/.bashrc
```
