13.2.5.3. 教程 5.3:紅綠燈 Traffic Light

1. 把 TB3 機器人放在車道上。如果正確放置,黃線應在機器人的左側,白線應在機器人的右側。 需確認 turtlebot3_bringup 套件的 turtlebot3_robot node 節點尚未啟動。如果它已經啟動,機器人將突然在軌道上運行。

2. [Remote PC 端] 開新的 terminal 視窗,輸入

 $ export AUTO_DT_CALIB=calibration
 $ roslaunch turtlebot3_autorace_detect turtlebot3_autorace_detect_traffic_light.launch

3. [Remote PC 端] 開新的 terminal 視窗,輸入

 $ rqt

點擊在視窗上方的 plugins -> visualization -> Image view,會產生一個攝影機視角圖的新視窗。用相同方式在 rqt 平板產生額外 4 個新視窗。然後在這 4 個新視窗,分別選擇 /detect/image_red_light , /detect/image_yellow_light , /detect/image_green_light ,及 /detect/image_traffic_light 的 topics。如果一切正常,三個螢幕將顯示紅色/黃色/綠色燈光的過濾影像,另一個螢幕將以短字串顯示識別出的顏色。在校準模式下,三個螢幕將顯示白色,另一個螢幕則單純顯示結果。此時,您應該調整過濾器參數,以顯示正確的車道線和方向。

4. [Remote PC 端] 開新的 terminal 視窗,輸入

 $ rosrun rqt_reconfigure rqt_reconfigure

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

提示:與教程 5.1 車道檢測相同

5. [Remote PC 端] 在覆寫了校準檔案後,可結束 rqt_rconfigure 及 turtlebot3_autorace_detect_traffic_light,然後輸入

 $ export AUTO_DT_CALIB=action
 $ roslaunch turtlebot3_autorace_detect turtlebot3_autorace_detect_traffic_light.launch

6. 使用 rqt_image_view node 節點來檢查是否輸出的結果正確。

Last updated