Turtlebot 2e 導航之 `move_base` 參數詳解: 環境代價地圖的設置

Turtlebot 2e 導航之move_base 參數詳解: 環境代價地圖的設置

通用代價設置costmap_common_params.yaml

costmap_common_params.yaml整個文件定義爲

max_obstacle_height: 0.60  # assume something like an arm is mounted on top of the robot

# Obstacle Cost Shaping (http://wiki.ros.org/costmap_2d/hydro/inflation)
robot_radius: 0.20  # distance a circular robot should be clear of the obstacle (kobuki: 0.18)
# footprint: [[x0, y0], [x1, y1], ... [xn, yn]]  # if the robot is not circular

map_type: voxel

obstacle_layer:
  enabled:              true
  max_obstacle_height:  0.6
  origin_z:             0.0
  z_resolution:         0.2
  z_voxels:             2
  unknown_threshold:    15
  mark_threshold:       0
  combination_method:   1
  track_unknown_space:  true    #true needed for disabling global path planning through unknown space
  obstacle_range: 2.5
  raytrace_range: 3.0
  origin_z: 0.0
  z_resolution: 0.2
  z_voxels: 2
  publish_voxel_map: false
  observation_sources:  scan bump
  scan:
    data_type: LaserScan
    topic: scan
    marking: true
    clearing: true
    min_obstacle_height: 0.25
    max_obstacle_height: 0.35
  bump:
    data_type: PointCloud2
    topic: mobile_base/sensors/bumper_pointcloud
    marking: true
    clearing: false
    min_obstacle_height: 0.0
    max_obstacle_height: 0.15
  # for debugging only, let's you see the entire voxel grid

#cost_scaling_factor and inflation_radius were now moved to the inflation_layer ns
inflation_layer:
  enabled:              true
  cost_scaling_factor:  5.0  # exponential rate at which the obstacle cost drops off (default: 10)
  inflation_radius:     0.5  # max. distance from an obstacle at which costs are incurred for planning paths.

static_layer:
  enabled:              true

解析(http://wiki.ros.org/costmap_2d/hydro/obstacles):

  • max_obstacle_height: 0.60 #傳感器讀數的最大有效高度,單位爲 meters; 通常設置爲略高於機器人的實際高度,高度是指包含機械臂打直情況下的最大高度。
  • robot_radius: 0.20 機器人半徑(圓形), kobuki是0.18m
  • footprint: [[x0, y0], [x1, y1], ... [xn, yn]] 當機器人非圓形時,先找機器人的旋轉中心,即兩個輪的中心點設置成(0,0),然後確定機器人擺放方向,x,y爲每個robot幾何型的每條邊的每個頂點。將所有頂點都列到其中。就完成了robot的footprint。
  • map_type: voxel 地圖類型,這裏爲voxel(體素地圖)。另一種地圖類型爲costmap(代價地圖)。這兩者之間的區別是前者是世界的3D表示,後者爲世界的2D表示。
  • obstacle_layer 障礙物層參數
    • enabled: true #啓用
    • max_obstacle_height: 0.6 傳感器讀數的最大有效高度(單位:m)。 通常設置爲略高於機器人的高度。 此參數設置爲大於全局max_obstacle_height參數的值將會失效。 設置爲小於全局max_obstacle_height的值將過濾掉傳感器上大於該高度以的點。
    • origin_z: 0.0 z原點,單位爲米,僅對voxel地圖
    • z_resolution: 0.2 z分辨率,單位meters/cell
    • z_voxels: 2 每個垂直列中的體素數目,ROS Nav功能包的默認值爲10。請參考《ROS導航功能調優指南》https://github.com/teddyluo/ROSNavGuide-Chinese
    • unknown_threshold: 15 當整列的voxel是“已知”(``known’’)的時候,含有的未知單元(“unknown”)的最大數量
    • mark_threshold: 0 整列voxel是“自由”(“free”)的時候,含有的已標記的cell(“marked”)的最大數目。
    • combination_method: 1 處理obstacle_laye之外的其他層傳入數據的行爲方式,枚舉型(enum)。可能的取值有:覆蓋已有值"Overwrite" (0), 取最大值"Maximum" (1), 什麼也不幹"Nothing" (99)。“覆蓋”僅是“覆蓋”其他層的數據,例如使得它們沒有生效。 “取最大值”是多數時候需要的。 它提取obstacle_layer或輸入數據中提供的數據的最大值。 “Nothing”根本不會改變傳入的數據。 請注意,這會極大地影響costmap的行爲方式,具體取決於您對track_unkown_space的設置。
    • track_unknown_space: true 如果爲false,每個像素具有兩種狀態之一:致命障礙(lethal)或自由(free)。 如果爲true,則每個像素具有3種狀態之一:致命障礙(lethal),自由(free)或未知(unknown)。
    • obstacle_range: 2.5 將障礙物插入代價地圖的最大範圍,單位爲 meters。
    • raytrace_range: 3.0 從地圖中掃描出障礙物的最大範圍,單位爲 meters 。
    • origin_z: 0.0 z原點,單位爲米,僅對voxel地圖(爲什麼定義2次?)
    • z_resolution: 0.2 (爲什麼定義2次?)
    • z_voxels: 2 (爲什麼定義2次?)
    • publish_voxel_map: false 是否發佈底層的體素柵格地圖,其主要用於可視化。
    • observation_sources: scan bump # 觀察源,我們這裏是激光數據(scan)和凸點數據(bump)。觀察源列表以空格分割表示,定義了下面參數中每一個 <source_name> 命名空間。
    • scan: 觀察源之一:激光數據。定義了:觀察源的數據類型,發佈話題,標記和添加障礙物
      • data_type: LaserScan 觀察源的數據類型:激光掃描
      • topic: scan 發佈話題爲scan
      • marking: true 啓用標記障礙物功能
      • clearing: true 啓用清除障礙物功能
        注:關於Marking and Clearing:
        • marking和clearing參數用來表示是否需要使用傳感器的實時信息來添加或清除代價地圖中的障礙物信息)
        • 代價地圖自動訂閱傳感器主題並自動更新。
        • 每個傳感器用於標記操作(將障礙物信息插入到代價地圖中),清除操作(從代價地圖中刪除障礙物信息)或兩者操作都執行。
        • 如果使用的是體素層,每一列上的障礙信息需要先進行投影轉化成二維之後才能放入代價地圖中。
      • min_obstacle_height: 0.25 傳感器最低有效讀數,以米爲單位。通常設置爲地面高度,但可以根據傳感器的噪聲模型設置爲更高或更低。
      • max_obstacle_height: 0.35 傳感器讀數的最大有效高度,以米爲單位。通常設置爲略大於機器人的最大高度。設置爲大於全局的max_obstacle_height的值會失效。設置爲小於全局max_obstacle_height將從傳感器上過濾掉該高度以上的點。
    • bump:觀察源之二:凸點數據。定義了:觀察源的數據類型,發佈話題,標記和添加障礙物功能及定義傳感器源數值的有效範圍
      • data_type: PointCloud2 數據類型爲點雲
      • topic: mobile_base/sensors/bumper_pointcloud Topic爲mobile_base/sensors/bumper_pointcloud
      • marking: true 啓用標記障礙物功能
      • clearing: false 關閉清除障礙物功能
      • min_obstacle_height: 0.0 傳感器最低有效讀數,以米爲單位。
      • max_obstacle_height: 0.15 傳感器讀數的最大有效高度,以米爲單位。
  • inflation_layer: 膨脹層參數
    • enabled: true 啓用膨脹地圖
    • cost_scaling_factor: 5.0 # exponential rate at which the obstacle cost drops off (default: 10)
      在膨脹期間應用於代價值的尺度因子。默認值:10。對在內接半徑之外的cells、以及在內接半徑之內的cells這兩種不同的cells, 代價函數的計算公式爲:
      exp(-1.0 * cost_scaling_factor * (distance_from_obstacle - inscribed_radius)) * (costmap_2d::INSCRIBED_INFLATED_OBSTACLE - 1)

其中costmap_2d::INSCRIBED_INFLATED_OBSTACLE當前取值爲254.注意:由於cost_scaling_factor在公式中乘以負數,因此增加該因子的值會減少它的cost。

對該效果討論請參考《ROS導航功能調優指南》。

  • inflation_radius: 0.5 # max. distance from an obstacle at which costs are incurred for planning paths.
    代價地圖膨脹半徑,以米爲單位。默認值:0.55
  • static_layer: 靜態地圖層
    • enabled: true 啓用靜態地圖

全局代價地圖的設置

全局代價地圖的設置主要有兩個文件:

<rosparam file="$(find turtlebot_navigation)/param/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find turtlebot_navigation)/param/global_costmap_params.yaml" command="load" />

其中,

  • costmap_common.yaml爲costmap的通用參數設置
  • global_costmap_params.yaml爲全局costmap的設置。
    costmap_common.yaml在前面已有介紹。這裏介紹global_costmap_params.yaml。它的定義爲:
global_costmap:
   global_frame: /map
   robot_base_frame: /base_footprint
   update_frequency: 1.0
   publish_frequency: 0.5
   static_map: true
   transform_tolerance: 0.5
   plugins:
     - {name: static_layer,            type: "costmap_2d::StaticLayer"}
     - {name: obstacle_layer,          type: "costmap_2d::VoxelLayer"}
     - {name: inflation_layer,         type: "costmap_2d::InflationLayer"}

解析:

  • global_frame: /map 全局代價地圖需要在map參考座標系下運行
  • robot_base_frame: /base_footprint 全局代價地圖使用機器人本體參考座標系
  • update_frequency: 1.0 全局地圖信息更新的頻率,單位是Hz
  • publish_frequency: 0.5 發佈頻率,用於顯示(例如rviz等)
  • static_map: true 代價地圖是否需要map_server提供的地圖信息進行初始化。如果不需要使用已有的地圖或者map_server,最好將該參數設置爲false
  • transform_tolerance: 0.5 tf變換最大延時
    global map引入了以下三層,經融合構成了master map,用於global planner
  • plugins: 插件定義
    -{name: static_layer, type: "costmap_2d::StaticLayer"} 靜態地圖層
    • {name: obstacle_layer, type: "costmap_2d::VoxelLayer"} 障礙地圖層
      這裏有個疑問:爲什麼obstacle_layer的類型不是普通的costmap_2d::ObstacleLayer?Turtlebot爲什麼將它設置爲costmap_2d::VoxelLayer?其實在costmap_common_params.yaml也提到了,開啓bump輸入源是爲了更好地可視化整個voxel層的情況,方便調試。所以這裏將obstacle_layer的地圖類型設置爲costmap_2d::VoxelLayer
    • {name: inflation_layer, type: "costmap_2d::InflationLayer"} 膨脹地圖層,用於留出足夠的安全距離

局部代價地圖的設置local_costmap_params.yaml

局部代價地圖的設置主要有兩個文件:

<rosparam file="$(find turtlebot_navigation)/param/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find turtlebot_navigation)/param/local_costmap_params.yaml" command="load" />

其中,

  • costmap_common.yaml爲costmap的通用參數設置,costmap_common.yaml在前面已有介紹。
  • `local_costmap_params.yaml’局部costmap的設置。

這裏介紹`local_costmap_params.yaml’。它的定義爲:

local_costmap:
   global_frame: odom
   robot_base_frame: /base_footprint
   update_frequency: 5.0
   publish_frequency: 2.0
   static_map: false
   rolling_window: true
   width: 4.0
   height: 4.0
   resolution: 0.05
   transform_tolerance: 0.5
   plugins:
    - {name: obstacle_layer,      type: "costmap_2d::VoxelLayer"}
    - {name: inflation_layer,     type: "costmap_2d::InflationLayer"}

解析

  • global_frame: odom 局部代價地圖使用odom座標系
  • robot_base_frame: /base_footprint 機器人本體參考座標系爲/base_footprint
  • update_frequency: 5.0 局部地圖更新頻率
  • publish_frequency: 2.0 發佈顯示頻率
  • static_map: false 不使用靜態地圖
  • rolling_window: true 與上面static_map相反,滾動窗口地圖,保持機器人處於中心位置
  • width: 4.0
  • height: 4.0
  • resolution: 0.05
    代價地圖寬(米)、高(米)和分辨率(米/格)。分辨率可以設置的與靜態地圖不同,但是一般情況下兩者是相同的。
  • transform_tolerance: 0.5 tf變換最大延時
  • plugins: 啓用的功能主要有:
    • {name: obstacle_layer, type: "costmap_2d::VoxelLayer"} 障礙層
    • {name: inflation_layer, type: "costmap_2d::InflationLayer"} 膨脹層

全局規劃器的設置

一般來說,全局路徑的規劃插件包括:

  • navfn:ROS:比較舊的代碼實現了dijkstra和A*全局規劃算法。
  • global_planner:重新實現了Dijkstra和A*全局規劃算法,可以看作navfn的改進版。
  • parrot_planner:一種簡單的算法實現全局路徑規劃算法。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章