ubuntu18.04、melodic。
1、导航包的组成
在局部导航算法的介绍之前我们需要先理解导航功能包中的各个组成部分:
在ROS中,进行导航需要使用到的三个包是:
(1) move_base:根据参照的消息进行路径规划,使移动机器人到达指定的位置;
(2) gmapping:根据激光数据(或者深度数据模拟的激光数据)建立地图;
(3) amcl:根据已经有的地图进行定位
move_base包中主要包含两个部分,全局路径规划(global planner)和局部路径规划(local planner)。
全局路径规划(global planner):根据给定的目标位置进行总体路径的规划,在ROS的导航中,首先会通过全局路径规划,计算出机器人到目标位置的全局路线。这一功能是navfn这个包实现的。navfn通过Dijkstra或A*等最优路径的算法,计算costmap上的最小花费路径,作为机器人的全局路线。
局部路径规划(local planner):根据附近的障碍物进行躲避路线规划。本地的实时规划是利用base_local_planner包实现的。该包使用Trajectory Rollout 和Dynamic Window approaches算法计算机器人每个周期内应该行驶的速度和角度(dx,dy,dtheta velocities)。
2、局部规划算法
(1)base_local_planner算法
- 它是move_base默认的局部规划包。该软件包提供了对平面上本地机器人导航的轨迹展开和动态窗口方法的实现。
-
base_local_planner配置方法:输入下面的命令进行安装
sudo apt-get install ros-melodic-base-local-planner
- base_local_planner使用方法:编写launch文件
<launch>
<!-- 设置地图的配置文件 -->
<arg name="map" default="cloister_gmapping.yaml" />
<!-- 运行地图服务器,并且加载设置的地图-->
<node name="map_server" pkg="map_server" type="map_server" args="$(find ares_navigation)/maps/$(arg map)">
</node>
<!-- 运行move_base节点 -->
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true">
<!--开启base_local局部导航节点-->
<param name="base_local_planner" value="base_local_planner/TrajectoryPlannerROS" />
<!--加载设置参数-->
<rosparam file="$(find teb_local_planner_tutorials)/cfg/omnidir/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find teb_local_planner_tutorials)/cfg/omnidir/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find teb_local_planner_tutorials)/cfg/omnidir/local_costmap_params.yaml" command="load" />
<rosparam file="$(find teb_local_planner_tutorials)/cfg/omnidir/global_costmap_params.yaml" command="load" />
<rosparam file="$(find ares_navigation)/config/ares/base_local_planner_params.yaml" command="load" />
</node>
<!-- 启动AMCL节点 -->
<include file="$(find amcl)/examples/amcl_omni.launch" >
</include>
<!-- 运行rviz -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find ares_navigation)/rviz/nav.rviz">
</node>
</launch>
- base_local_planner使用效果:效果并不是很好,局部路径规划很短,小车行动缓慢且经常偏离轨迹,一般不会直接使用它作为局部路径规划算法。
(2)dwa_local_planner算法
-
dwa_local_planner配置方法:可输入下面的命令进行安装
-
sudo apt-get install ros-melodic-dwa-local-planner
检测是否安装成功:
roscd dwa_local_planner
创建launch文件 如下:
<launch> <!-- 设置地图的配置文件 --> <arg name="map" default="cloister_gmapping.yaml" /> <!-- 运行地图服务器,并且加载设置的地图--> <node name="map_server" pkg="map_server" type="map_server" args="$(find ares_navigation)/maps/$(arg map)"/> <!-- 运行move_base节点 --> <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true"> <!--开启dwa局部导航节点--> <param name="base_local_planner" value="dwa_local_planner/DWAPlannerROS" /> <!--加载设置参数--> <rosparam file="$(find ares_navigation)/config/ares/costmap_common_params.yaml" command="load" ns="global_costmap" /> <rosparam file="$(find ares_navigation)/config/ares/costmap_common_params.yaml" command="load" ns="local_costmap" /> <rosparam file="$(find ares_navigation)/config/ares/local_costmap_params.yaml" command="load" /> <rosparam file="$(find ares_navigation)/config/ares/global_costmap_params.yaml" command="load" /> <rosparam file="$(find ares_navigation)/config/ares/move_base_params.yaml" command="load" /> <rosparam file="$(find ares_navigation)/config/ares/dwa_local_planner_params.yaml" command="load" /> </node> <!-- 启动AMCL节点 --> <include file="$(find amcl)/examples/amcl_omni.launch" /> <!-- 运行rviz --> <node pkg="rviz" type="rviz" name="rviz" args="-d $(find ares_navigation)/rviz/nav.rviz"/> </launch>
运行该文件。绿色的线是全局规划的路线,蓝色的短线表示局部规划的路线
(3)teb_local_planner算法
teb_local_planner则是2D导航堆栈的base_local_planner的插件。实现了一个在线优化的本地轨迹规划器,用于导航和控制移动机器人,作为ROS 导航包的插件。全局规划器生成的初始轨迹在运行时期间进行优化,最小化轨迹执行时间(时间最优目标), 与障碍物分离并符合动力学约束,例如满足最大速度和加速度。
- teb_local_planner配置方法:
sudo apt-get install ros-melodic-teb-local-planner
验证是否安装成功
roscd teb_local_planner
-
teb_local_planner使用方法:
1.安装[teb_local_planner_tutorials](http://wiki.ros.org/teb_local_planner_tutorials)软件包
2.检查参数/配置文件
3.启动diff_drive设置:
$ roslaunch teb_local_planner_tutorials robot_diff_drive_in_stage.launch
4.使用rosrun rqt_reconfigure rqt_reconfigure或修改文件来修改参数。