Move_base Tuining
前言
- 應項目需求,我需要調整move_base參數,使得機器人可以精確旋轉到指定角度,之前只能實現較為精確的到達(x,y)坐標,現在要求,又要精確又要不震盪地達到目標要求。
- 需要全面了解局部避障算法,才能正確地調整參數。
- 全面定制ros_navigation_stack基本能夠完成機器人導航要求
Move_base Tuining
前言
參考
任務要求
學習記錄
基本調參指南
確定激光或者聲納的完整性
里程計的有效性
定位的有效性
代價地圖
局部規划器
局部規划器原理
各模塊參數
代價地圖
障礙層地圖參數
Sensor management parameters
Global Filtering Parameters
ObstacleCostmapPlugin
VoxelCostmapPlugin
膨脹地圖
move_base參數
move_base狀態機宏觀行為控制
恢復行為狀態定制
可以定制的地方
參數調整要點
實際調參筆記
以前的筆記
代價地圖
綜述
標記與清除
占據與釋放,未知區域(區域的三種屬性)
地圖更新
tf
代價值
地圖類型
參考
Basic Guide
Local Planner
Move_base setup
Move_base Param
局部規划器的動態窗口法
航跡推演odometry
DWA算法分析
base_local_planner
任務要求
- 了解dynamic window局部規划原理,調整局部規划器的功能,使得正常避障。
- 了解當前上層規划策略,調整move_base離散規划的策略,重點是調整其狀態機。
- 看看Action功能能不能和LV端協作起來完成功能。
本項目立足未知大環境下的導航,特點是:只有基於節點的拓撲地圖,沒有使用激光SLAM工具制圖與定位,因為在未知大環境下,無法預先進行制圖,即使進行SLAM,環境數據太大太多,故使用先驗的全局地圖,機器人在運行過程中動態維護該地圖(如基於視覺的語義標簽),在維護的過程中進行動態的語義規划,激光等傳感器只用於局部規划器,在局部的動態環境中進行路勁規划是用於避障。
路徑規划的定義:在約束條件(能量消耗最少,路徑最短,躲避障礙)下對機器人(在其工作空間中)從一個狀態到另一個狀態的路徑的求解。
SLAM:同時定位和制圖,主要包括三個點,定位,制圖,導航(路徑規划,包括全局路徑規划,局部路徑規划,軌跡生成)
全局路徑規划
學習記錄
基本調參指南
確定激光或者聲納的完整性
- 一般可以通過rviz來確認
- 本項目中,傳感器的有效性由購買的先鋒機器人保證
里程計的有效性
- 一般分為旋轉和平移,旋轉可以使用原地旋轉,平移可以沿着牆行走看看位置數據變化。
- 本項目中,里程計由先鋒機器人的IMU保證
定位的有效性
- 查看AMCL是否運行有效
- 本項目中,使用人工定位方法,即機器人在出生點時被指定當前坐標。
代價地圖
- 機器人導航所用地圖有多種,包括拓撲地圖(節點地圖),精確分解地圖,占據柵格地圖(不精確的分解地圖)等,ROS導航包中采用分層的柵格代價地圖,這是David.Lu!!在13-14年接手NavStack后所做的一些工作,如一層sensor_msgs/Range構建的激光地圖range_sensor_layer,一層由監測到的人的位置所構建的social_layer,每一層接收一種特定的傳感特征信息或執行一種特定權值計算算法,通過不同的柵格賦值策略,將costmap的值修改,達到改變機器人行為的目的。到底是如何改變機器人行為的呢,主要是在局部規划中改變機器人的運動軌跡。
- 代價地圖分層,具體做法是將不同類型的柵格賦值過程通過pluginlib進行解耦和隔離, 每一種不同的柵格類型抽象成一層,layer,每一層可以使用不同的傳感器數據輸入, 不同的柵格賦值策略,當然最后還是合成一個當前內置的地圖層包括:Static Map Layer; Obstacle Map Layer(二維或三維); Inflation Layer
- costmap_2d package中實現了帶權柵格地圖 的環境表示方式. 作為導航架構中環境表示模塊,承擔了與傳感器數據流交互,暴露接口給planner進行規划
- Costmap_2d主要流程為輸入激光雷達laserscan 或者點雲 pointcloud 數據(當然可以自己定義別的), 從tf tree上獲取定位數據, 進行已知定位數據的建圖處理. 因為是根據已知定位數據的建圖算法,假設定位數據精確. 所以如何選取全局定位坐標系,很大程度上決定了建圖質量, 很多問題也源於此.
- Costmap 除去參數設置和多線程調度, 已知定位數據的建圖 核心步驟是raytrace過程.算法過程如下:
- 得到當前時刻的機器人當前的全局位置pos, 傳感器相對機器人中心坐標系偏移offset, 將不同的傳感器數據統一處理成點雲, 將傳感器中心以及點雲數據轉換到全局坐標系.
- 根據傳感器模型,從傳感器中心到點雲的連線, 這一部分空間為沒有障礙物的安全空間free, 點雲的位置為障礙物所在位置occupied, 根據我們對於costmap中, 柵格cost的定義, 對連線上賦權值. 一般使用bresenham算法將直線離散化到柵格中.
- 確定了free 和 occupied的柵格, 根據costmap 中對柵格權值的分類,將unkown 和inflation 等部分的權值填上, inflation 使用廣度優先的方式進行擴展柵格, 將occupied 的柵格入隊, 然后層層擴展,得到膨脹出去的柵格,並賦值.
局部規划器
- 首先需要選擇是dwa還是base_local_planner
- 最重要的參數是加速度的上限值需要明確和一致,因為局部規划器就是基於這些值做模擬,
局部規划器原理
<1 由移動底盤的運動學模型得到速度的采樣空間.
在給定的速度加速度限制下, 在給定時間間隔下, 沒有碰撞的速度為admission velocity.
(這些給定的限制都是我們需要調試的參數)
<2 在采樣空間中, 我們計算每個樣本的目標函數:
NF =α ⋅vel + β ⋅nf +γ ⋅Δnf +δ ⋅ goal
Vel 當前速度值
Nf 到當前目標點的相關的cost 值
Δnf 與全局路徑的貼合程度的cost 值
Goal 到全局目標點的距離值.
還有一些cost可以自己定義, navigation實現中還有對最大最小障礙物距離的cost 與傾向於向前走的cost.
然后α,β,γ,δ 都是權重參數, 調節這些參數可以極大影響機器人避障行為
<3 得到期望速度, 插值成軌跡輸出給move_base
各模塊參數
代價地圖
- Coordinate frame and tf parameters
~<name>/global_frame (string, default: "/map")
The global frame for the costmap to operate in.代價地圖在哪一個坐標系的基礎上制作
~<name>/robot_base_frame (string, default: "base_link")
The name of the frame for the base link of the robot.傳感器數據轉換為地圖上數據的橋梁
~<name>/transform_tolerance (double, default: 0.2)
Specifies the delay in transform (tf) data that is tolerable in seconds. This parameter serves as a safeguard to losing a link in the tf tree while still allowing an amount of latency the user is comfortable with to exist in the system. For example, a transform being 0.2 seconds out-of-date may be tolerable, but a transform being 8 seconds out of date is not. If the tf transform between the coordinate frames specified by the global_frame and robot_base_frame parameters is transform_tolerance seconds older than ros::Time::now(), then the navigation stack will stop the robot.延遲時間,和實時性要求有關,這個時間參數實際上是允許TF傳輸延遲,參數設置過大會影響機器人的行為。
- Rate parameters
~<name>/update_frequency (double, default: 5.0)
The frequency in Hz for the map to be updated.圖的更新頻率,需要配合傳感器數據的發布頻率。考慮機器人處理器速度。
~<name>/publish_frequency (double, default: 0.0)
The frequency in Hz for the map to be publish display information.發布頻率,主要被RViz接收,需要考慮地圖大小來設置發布頻率。
- Map management parameters
~<name>/rolling_window (bool, default: false)
Whether or not to use a rolling window version of the costmap. If the static_map parameter is set to true, this parameter must be set to false.
~<name>/always_send_full_costmap (bool, default: false)
If true the full costmap is published to "~<name>/grid" every update. If false only the part of the costmap that has changed is published on the "~<name>/grid_updates" topic.
- The following parameters can be overwritten by some layers, namely the static map layer.
~<name>/width (int, default: 10)
The width of the map in meters.地圖的幾何參數,也會影響路徑規划精度。
~<name>/height (int, default: 10)
The height of the map in meters.
~<name>/resolution (double, default: 0.05)
The resolution of the map in meters/cell.
~<name>/origin_x (double, default: 0.0)
The x origin of the map in the global frame in meters.
~<name>/origin_y (double, default: 0.0)
The y origin of the map in the global frame in meters.
障礙層地圖參數
障礙地圖基於激光點雲數據,給代價地圖標上障礙物信息。
Sensor management parameters
~<name>/observation_sources (string, default: "")
A list of observation source names separated by spaces. This defines each of the <source_name> namespaces defined below.
Each source_name in observation_sources defines a namespace in which parameters can be set:
~<name>/<source_name>/topic (string, default: source_name)
The topic on which sensor data comes in for this source. Defaults to the name of the source.
~<name>/<source_name>/sensor_frame (string, default: "")
The frame of the origin of the sensor. Leave empty to attempt to read the frame from sensor data. The frame can be read from both sensor_msgs/LaserScan, sensor_msgs/PointCloud, and sensor_msgs/PointCloud2 messages.
~<name>/<source_name>/observation_persistence (double, default: 0.0)
How long to keep each sensor reading in seconds. A value of 0.0 will only keep the most recent reading.
~<name>/<source_name>/expected_update_rate (double, default: 0.0)
How often to expect a reading from a sensor in seconds. A value of 0.0 will allow infinite time between readings. This parameter is used as a failsafe to keep the navigation stack from commanding the robot when a sensor has failed. It should be set to a value that is slightly more permissive than the actual rate of the sensor. For example, if we expect a scan from a laser every 0.05 seconds we might set this parameter to be 0.1 seconds to give a generous buffer and account for some amount of system latency.
~<name>/<source_name>/data_type (string, default: "PointCloud")
The data type associated with the topic, right now only "PointCloud", "PointCloud2", and "LaserScan" are supported.
~<name>/<source_name>/clearing (bool, default: false)
Whether or not this observation should be used to clear out freespace.
~<name>/<source_name>/marking (bool, default: true)
Whether or not this observation should be used to mark obstacles.
~<name>/<source_name>/max_obstacle_height (double, default: 2.0)
The maximum height in meters of a sensor reading considered valid. This is usually set to be slightly higher than the height of the robot. Setting this parameter to a value greater than the global max_obstacle_height parameter has no effect. Setting this parameter to a value less than the global max_obstacle_height will filter out points from this sensor above that height.
~<name>/<source_name>/min_obstacle_height (double, default: 0.0)
The minimum height in meters of a sensor reading considered valid. This is usually set to be at ground height, but can be set higher or lower based on the noise model of your sensor.
~<name>/<source_name>/obstacle_range (double, default: 2.5)
The maximum range in meters at which to insert obstacles into the costmap using sensor data.
~<name>/<source_name>/raytrace_range (double, default: 3.0)
The maximum range in meters at which to raytrace out obstacles from the map using sensor data.
~<name>/<source_name>/inf_is_valid (bool, default: false)
Allows for Inf values in "LaserScan" observation messages. The Inf values are converted to the laser maximun range.
Global Filtering Parameters
Apply to all sensors.
~<name>/max_obstacle_height (double, default: 2.0)障礙高度
The maximum height of any obstacle to be inserted into the costmap in meters. This parameter should be set to be slightly higher than the height of your robot.
~<name>/obstacle_range (double, default: 2.5)障礙范圍:多少米范圍內的障礙物被標識出來
The default maximum distance from the robot at which an obstacle will be inserted into the cost map in meters. This can be over-ridden on a per-sensor basis.
~<name>/raytrace_range (double, default: 3.0)不知道啊,只知道raytrace是一種代價值傳播的方法。
The default range in meters at which to raytrace out obstacles from the map using sensor data. This can be over-ridden on a per-sensor basis.
ObstacleCostmapPlugin
This parameter is only used by the ObstacleCostmapPlugin
~<name>/track_unknown_space (bool, default: false)
Specifies whether or not to track what space in the costmap is unknown, meaning that no observation about a cell has been seen from any sensor source.
VoxelCostmapPlugin
The following parameters are only used by the VoxelCostmapPlugin
~<name>/origin_z (double, default: 0.0)
The z origin of the map in meters.
~<name>/z_resolution (double, default: 0.2)
The z resolution of the map in meters/cell.
~<name>/z_voxels (int, default: 10)
The number of voxels to in each vertical column, the height of the grid is z_resolution * z_voxels.
~<name>/unknown_threshold (int, default: ~<name>/z_voxels)
The number of unknown cells allowed in a column considered to be "known"
~<name>/mark_threshold (int, default: 0)
The maximum number of marked cells allowed in a column considered to be "free".
~<name>/publish_voxel_map (bool, default: false)
Whether or not to publish the underlying voxel grid for visualization purposes.
膨脹地圖
膨脹地圖指的是代價值從障礙物處向外側進行的傳播,傳播后代價值有5個標識值:254,253,128,1,0。以127為界,以上為可能有障礙物,以下為應該沒有障礙物。
~<name>/inflation_radius (double, default: 0.55)
The radius in meters to which the map inflates obstacle cost values.
~<name>/cost_scaling_factor (double, default: 10.0)
A scaling factor to apply to cost values during inflation. The cost function is computed as follows for all cells in the costmap further than the inscribed radius distance and closer than the inflation radius distance away from an actual obstacle: exp(-1.0 * cost_scaling_factor * (distance_from_obstacle - inscribed_radius)) * (costmap_2d::INSCRIBED_INFLATED_OBSTACLE - 1), where costmap_2d::INSCRIBED_INFLATED_OBSTACLE is currently 254. NOTE: since the cost_scaling_factor is multiplied by a negative in the formula, increasing the factor will decrease the resulting cost values.
move_base參數
~base_global_planner (string, default: "navfn/NavfnROS" For 1.1+ series)
The name of the plugin for the global planner to use with move_base, see pluginlib documentation for more details on plugins. This plugin must adhere to the nav_core::BaseGlobalPlanner interface specified in the nav_core package. (1.0 series default: "NavfnROS")
~base_local_planner (string, default: "base_local_planner/TrajectoryPlannerROS" For 1.1+ series)
The name of the plugin for the local planner to use with move_base see pluginlib documentation for more details on plugins. This plugin must adhere to the nav_core::BaseLocalPlanner interface specified in the nav_core package. (1.0 series default: "TrajectoryPlannerROS")
~recovery_behaviors (list, default: [{name: conservative_reset, type: clear_costmap_recovery/ClearCostmapRecovery}, {name: rotate_recovery, type: rotate_recovery/RotateRecovery}, {name: aggressive_reset, type: clear_costmap_recovery/ClearCostmapRecovery}] For 1.1+ series)
~controller_frequency (double, default: 20.0)
The rate in Hz at which to run the control loop and send velocity commands to the base.
~planner_patience (double, default: 5.0)
How long the planner will wait in seconds in an attempt to find a valid plan before space-clearing operations are performed.
~controller_patience (double, default: 15.0)
How long the controller will wait in seconds without receiving a valid control before space-clearing operations are performed.
move_base狀態機宏觀行為控制
~conservative_reset_dist (double, default: 3.0)
The distance away from the robot in meters at which obstacles will be cleared from the costmap when attempting to clear space in the map. Note, this parameter is only used when the default recovery behaviors are used for move_base.
~recovery_behavior_enabled (bool, default: true)
Whether or not to enable the move_base recovery behaviors to attempt to clear out space.在本項目中應該為否
~clearing_rotation_allowed (bool, default: true)
Determines whether or not the robot will attempt an in-place rotation when attempting to clear out space. Note: This parameter is only used when the default recovery behaviors are in use, meaning the user has not set the recovery_behaviors parameter to anything custom.在本項目中應該為否
~shutdown_costmaps (bool, default: false)
Determines whether or not to shutdown the costmaps of the node when move_base is in an inactive state
~oscillation_timeout (double, default: 0.0)
How long in seconds to allow for oscillation before executing recovery behaviors. A value of 0.0 corresponds to an infinite timeout. New in navigation 1.3.1
~oscillation_distance (double, default: 0.5)
How far in meters the robot must move to be considered not to be oscillating. Moving this far resets the timer counting up to the ~oscillation_timeout New in navigation 1.3.1
~planner_frequency (double, default: 0.0)
The rate in Hz at which to run the global planning loop. If the frequency is set to 0.0, the global planner will only run when a new goal is received or the local planner reports that its path is blocked. New in navigation 1.6.0
恢復行為狀態定制
~<name>/sim_granularity (double, default: 0.017)
The distance in radians between checks for obstacles when checking if an in-place rotation is safe. Defaults to 1 degree.
~<name>/frequency (double, default: 20.0)
The frequency in HZ at which to send velocity commands to the mobile base.
可以定制的地方
- 這里記錄除了參數調整之外,還可以進行程序定制的模塊。
- 機器人64X50X65cm
- 全局規划器(采用不同的規划策略,離散策略都可以)
- 局部規划器
- 恢復行為
- move_base狀態機
- 動作服務端編程
- 層次代價地圖(局部規划器,改變機器人行為,改動潛力大)
- 地圖維護
參數調整要點
- 全局代價地圖所在坐標系與局部代價地圖一樣都在odometry,全局代價地圖尺寸建議比局部地圖大。
- 查看計算機性能的一個指標是CPU利用率
- 全局代價地圖的膨脹半徑應該比局部的大一點,這樣可以在全局規划時規划出較安全的路徑,而在局部規划時給與較大的自由。(個人理解)
- 地圖分辨率可不可以設小一點,更加精確。
- 膨脹地圖半徑一般為機器人的半徑,如果想要機器人更加冒險,應該增加cose_scaling_factor值,比如到100
- 將move_base的恢復行為去掉
- 代價地圖的分辨率不可設置太小,不然全局路徑可能會不平滑。但是平滑的軌跡不是由全局路徑規划器來決定的,而是局部規划器來決定的,所以局部分辨率可以設置得高,但是會增加計算機壓力,地圖的生成會變慢,對於真機應該不是問題。
- 為了使機器人運動更精確,嘗試使局部規划器的位置公差參數調整至+-0.05。
實際調參筆記
- 全局代價地圖的膨脹距離過大,需要調小,建議與局部規划器地圖一樣大
- 記得開啟zsProxy
- 計算機性能不是問題,參數設置良好,局部規划器比較准
- 網絡有點卡,建議降低數據發布頻率或者降低地圖分辨率(只是顯示卡,還是不改了)
- 在真機上實驗需要修改若干文件
以前的筆記
代價地圖
綜述
- 紅色的是障礙物,藍色的是障礙物的膨脹區域,紅色多邊形是機器人的輪廓,要做到避障,機器人的輪廓始終不能穿過藍色區域,更不用說紅色區域
- 現有的功能是二維地圖,只能做平面規划,但是障礙層地圖可以是三維的
標記與清除
- 通過訂閱特定傳感器主題消息來更新地圖
占據與釋放,未知區域(區域的三種屬性)
- 每一個網格都都可以有255種值(顏色),不過一般來講只有三種顏色,要么是空的,要么是占據的,要么是未知的
地圖更新
- 更新頻率可以用參數控制
tf
- 為了適當地插入傳感器數據,需要有合適的左邊變換
代價值
- Lethal
- 一個確定的障礙物
- Inscribed(記名的)
- 是一個障礙物,只是距離較遠
- Possibly circumscribed
- 使用另一個距離閾值來度量的障礙物
- Freespace
- 零,沒有任何東西,機器人不應該去那兒
- Unknown
- 沒有信息
- 其他
地圖類型
- 第一種是static_map,第二種是設定好長和寬的rolling_window,這種地圖會隨着機器人的移動而移動。