> 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/11.-simulation-mo-ni/11.2.-shi-yong-gazebo-mo-ni-qi-lai-jin-hang-tb3-mo-ni/11.2.2.-chan-du-de-gazebo-cha-jian/11.2.2.1.-ru-he-shi-yong-gazebo-plugin-cha-jian.md).

# 11.2.2.1. 如何使用 Gazebo Plugin 插件

**1) 安裝 Gazebo7 程式庫**

```
$ sudo apt-get install libgazebo7-dev
```

**2) 從 Github 下載插件原始碼**

```
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_gazebo_plugin
```

**3) 將 Gazebo 插件路徑加入 .bashrc 檔**

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

{% hint style="info" %}
Tip：turtlebot3\_gazebo\_plugin path = \~/turtlebot3\_gazebo\_plugin
{% endhint %}

```
export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${turtlebot3_gazebo_plugin path}/build
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${turtlebot3_gazebo_plugin path}/models
```

**4) Make 及 Build**

```
$ cd ${turtlebot3_gazebo_plugin path}
$ mkdir build
$ cd build
$ cmake ..
$ make
```

**5) 執行 plugin 插件**

{% hint style="info" %}
Tip：在執行指令前，必須先指定 TurtleBot3 的 model 模型名稱。${TB3\_MODEL} 是表示所使用的 burger, waffle, waffle\_pi 模型的名稱。如果你要永久設定 export setting，請參考 [**Export TURTLEBOT3\_MODEL**](http://emanual.robotis.com/docs/en/platform/turtlebot3/export_turtlebot3_model) 網頁。
{% endhint %}

```
$ cd ${turtlebot3_gazebo_plugin}
$ gazebo worlds/turtlebot3_${TB3_MODEL}.world
```

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-Ll0D5xCT7Hgaidj8tPb%2F-Ll0byf__xAn902d5jm6%2Fgazebo_waffle_pi.png?alt=media&amp;token=edc36f24-ef34-4631-b40b-887e99e8e6af" alt=""></div>

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-Ll0D5xCT7Hgaidj8tPb%2F-Ll0c1QMz2kRXS7EXw53%2Fgazebo_burger.png?alt=media&amp;token=e16942e1-109c-4e8a-bac2-7f6b59ed9a10" alt=""></div>

**6) 鍵盤遙控操作**

```
w - set linear velocity up
x - set linear velocity down
d - set angular velocity up
a - set angular velocity down
s - set all velocity to zero
```

**7) Topic Subscribe 訂閱 topic 指令**

* 顯示全部 topic

```
$ gz topic -l
```

* 訂閱光達 scan 數據

```
$ gz topic -e /gazebo/default/user/turtlebot3_${TB3_MODEL}/lidar/hls_lfcd_lds/scan
```

* 訂閱攝影機影像數據

**Waffle 鬆餅款** (Intel RealSense R200)

```
$ gz topic -e /gazebo/default/user/turtlebot3_waffle/image/intel_realsense_r200/image
```

**Waffle Pi 鬆餅 Pi 款** (Raspberry Pi camera)

```
$ gz topic -e /gazebo/default/user/turtlebot3_waffle_pi/image/raspberry_pi_cam/image
```

**8) 執行 listener**

```
$ cd ${turtlebot3_gazebo_plugin}/build
$ ./lidar_listener ${TB3_MODEL}
```

打開新的 terminal 視窗輸入下方指令。

```
$ cd ${turtlebot3_gazebo_plugin}/build
$ ./image_listener ${TB3_MODEL}
```

**參考資源：**&#x20;

* [**Gazebo API** ](http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/index.html)
* [**How to contribute model** ](http://gazebosim.org/tutorials?tut=model_contrib\&cat=build_robot)
* [**How to make model** ](http://gazebosim.org/tutorials?tut=build_model\&cat=build_robot)
* [**Tutorial for making Hello World plugin** ](http://gazebosim.org/tutorials?tut=plugins_hello_world\&cat=write_plugin)
* [**Tutorial for making model plugin**](http://gazebosim.org/tutorials?cat=guided_i\&tut=guided_i5)&#x20;
* [**Tutorial for making sensor plugin** ](http://gazebosim.org/tutorials?tut=contact_sensor)
* [**Tutorial for topic subscription**](http://gazebosim.org/tutorials?tut=topics_subscribed)
