> 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/13.-autonomous-driving-zi-dong-jia-shi/13.2.-tb3-autorace-tiao-zhan-sai-jiao-cheng/13.2.5.-jiao-cheng-5-jie-ge-bie-ren-wu/13.2.5.5.-jiao-cheng-5.5-ping-jiao-dao-kou-level-crossing.md).

# 13.2.5.5. 教程 5.5：平交道口 Level Crossing

1\. 平交道口是找出在柵欄上的三個紅色矩形，並判別柵欄是否升起或放下，及 TB3 機器人須距離多近

2\. 適當地將機器人放在車道上，然後把 TB3 機器人帶到放下的柵欄前。

3\. **\[Remote PC 端]** 開新的 terminal 視窗，輸入

```
 $ export AUTO_DT_CALIB=calibration
 $ roslaunch turtlebot3_autorace_detect turtlebot3_autorace_detect_level.launch
```

4\. **\[Remote PC 端]** 開新的 terminal 視窗，輸入

```
$ rqt
```

點擊在視窗上方的 plugins -> visualization -> Image view，會產生一個攝影機視角圖的新視窗。用相同方式在 rqt 平板產生額外 3 個新視窗。然後在這 3 個新視窗，分別選擇 /detect/image\_level\_color\_filtered，及 /detect/image\_level 的 topics。如果一切正常，三個螢幕將顯示紅色矩形的過濾影像，另一個螢幕將會畫出一條連接三個矩形的線條。在校準模式下，一個螢幕將顯示白色，另一個螢幕則單純顯示結果。此時，您應該調整過濾器參數，以顯示正確的車道線和方向。

5\. **\[Remote PC 端]** 開新的 terminal 視窗，輸入

```
$ rosrun rqt_reconfigure rqt_reconfigure
```

然後調整 /detect\_level 中的參數值。更改 color filter 顏色過濾器的數值後，則在每種顏色的螢幕上，將顯示更改的過濾視角圖。之後，將值覆寫到turtlebot3\_autorace\_detect/param/level/ 中的 level.yaml 檔案。這會使攝影機在下次啟動時，使用你所設置的參數。

{% hint style="info" %}
提示：與教程 5.1 車道檢測相同
{% endhint %}

6\. **\[Remote PC 端]** 在覆寫了校準檔案後，可結束 rqt\_rconfigure 及 turtlebot3\_autorace\_detect\_level，然後輸入

```
 $ export AUTO_DT_CALIB=action
 $ roslaunch turtlebot3_autorace_detect turtlebot3_autorace_detect_level.launch
```

7\. 使用 rqt\_image\_view node 節點來檢查輸出的結果是否正確。
