navigation 加圖層,導致全域性規劃讀取不到引數,全域性規劃不可用問題。
阿新 • • 發佈:2021-06-18
1.yaml 加圖層,yaml檔案輸入容易出錯,最好複製格式修改內容,手動輸入英文輸入法輸入。
plugins: - {name: static_layer, type: "costmap_2d::StaticLayer"} - {name: virtuals, type: "costmap_2d::VirtualLayer"} - {name: obstacles, type: "costmap_2d::ObstacleLayer"} - {name: inflation_layer, type: "costmap_2d::InflationLayer"}
2.加圖層導致整個地圖的異常?在這裡困住了兩天,沒發現原因,主要是由於加了圖層之後,costmap_2d_ros可以讀取到plugins 引數了。原先yaml 檔案中沒有plugins 引數。
因此其他圖層包括障礙物圖層的ros::NodeHandle namespace 名稱空間發生變化。可以執行時打印出來看看。使用nh.getNamespace() 函式獲取。可以發現和之前不一樣了。
解決方法:1. 在costmap_2d_ros圖層初始化時候去掉/pname,保證名字一致。
plugin->initialize(layered_costmap_, name + "/" + pname, &tf_);
方法2. 修改讀取不到的配置引數字首:加圖層名字,這樣也可以讀取到引數。
observation_sources: scan scan: {sensor_frame: base_scan, data_type: LaserScan, topic: scan, marking: true, clearing: true} 改為: obstacles: observation_sources: scan scan: {sensor_frame: base_scan, data_type: LaserScan, topic: scan, marking: true, clearing: true}